I would get all users who *are* following and then look up everyone except 
them.

$followers = $this->User->Follow->find('all', array(
'conditions' => array(
  'Follow.followed_by' => $this->Auth->user('id')
)
));

$nonfollowers = $this->User->find('all', array(
'conditions' => array(
  'not' => array(
    'User.id' => Set::extract('/Follow/followed_to', $followers)
  )
)
));

On Sunday, March 4, 2012 11:02:17 PM UTC-8, Wasif wrote:
>
> Hi all, 
>
> I am writing a function and i would like to call all the site users 
> who are not being followed by the session user. 
>
> I am stuck here since 2 days, could anyone help me here? 
>
> function people() { 
> $options=array( 
>          
> 'fields'=>array('User.id','User.fname','User.lname','User.f_id','Follow.followed_by','Follow.followed_to'),
>  
>
>                                            
> 'joins'=>array(array('table'=>'follows', 
>                                                                               
>           'alias'=>'Follow', 
>
>                                                                               
>           'type'=>'left', 
>
>                                                                               
>           'conditions'=>array('Follow.followed_by!='.$this->Session- 
>
> >read('Auth.User.id'),'Follow.followed_to=User.id'))), 
>                                            'group'=>'User.id', 
>                                            
> 'conditions'=>array('User.f_id'=>1), 
>                                            ); 
>                 $this->set('users',$this->User->find('all',$options)); 
> }

-- 
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