I am stuck on a query problem :
These are the tables involved :

Group
    id
    name

User
    id
    name

Groups_Users   (for HABTM)
   id
   group_id
   user_id

Now i have an admin system that lets the admin view the group and all
the related users.
Which is working fine. However, I want to do the OPPOSITE.
View the group and display ALL the users that are not in that group.
How would I structure my $find statement?

Obviously, this is wrong but it is what i need it to do :
            $users = $this->User->find('all',array('conditions'=>

                        array('NOT'=>array('User.id' =>
'GroupsUser.user_id')))

                        );

This next set of code, is what i want it to do, but not have to
explicitly declare the user ids
This would return all users NOT 1,2,3,4.

                    $filter = array(1,2,3,4);
                     $users = $this->User->find('all',array
('conditions'=>
                             array('NOT'=>array('User.id' =>
$filter)))
                        );

would appreciate all help.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to