Is your User model associated with UserUsers? You said that User HABTM
User. What is the alias you're using for that? UserUsers?

And is this function in the controller or model? If model, then
$this->UserUsers->find()

On Wed, Jul 4, 2012 at 5:12 PM, JonStark <jean...@gmail.com> wrote:
> Thanks for the advice, but when I tried this, it returned :
>
> Call to a member function find() on a non-object
>
> for this code :
>
>> public function countFollowing($id) {
>> $user = $this->User->UserUsers->find('all', array(
>> 'conditions' => array(
>> 'follower_id' => $id
>> ),
>> ));
>> debug($user);
>>     }
>
>
> Any further advice ?
>
> Many thanks !
>
>
>
>
> Le mercredi 4 juillet 2012 21:01:08 UTC+2, cricket a écrit :
>>
>> Because your User table has no such column. Try running the find on
>> the associated model.
>>
>> $this->User->UserUsers->find(...)
>>
>>
>> On Wed, Jul 4, 2012 at 2:38 PM, JonStarkwrote:
>> > Hi everyone !
>> >
>> > I have a question that shouldn't be that hard but I really can't manage
>> > it :
>> >
>> > In my app, User HABTM User
>> >
>> > users_users table is : id, following_id, follower_id
>> >
>> > I want to count every user where follower id is $id.
>> >
>> > This is my function :
>> >
>> >> public function countFollowing($id) {
>> >> $user = $this->User->find('all', array(
>> >> 'conditions' => array(
>> >> 'UserUsers.follower_id' => $id
>> >> ),
>> >> ));
>> >> count($user);
>> >>     }
>> >
>> >
>> > But it returns Error: SQLSTATE[42S22]: Column not found: 1054 Unknown
>> > column
>> > 'UserUsers.follower_id' in 'where clause'...
>> >
>> > Any idea why ? Thanks a lot for your time !
>> >
>> > --
>> > Our newest site for the community: CakePHP Video Tutorials
>> > http://tv.cakephp.org
>> > Check out the new CakePHP Questions site http://ask.cakephp.org and help
>> > others with their CakePHP related questions.
>> >
>> >
>> > To unsubscribe from this group, send email to
>> > cake-php+unsubscr...@googlegroups.com For more options, visit this group
>> > at
>> > http://groups.google.com/group/cake-php
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to