On 23 mayo, 01:23, Brian Hartvigsen <[EMAIL PROTECTED]> wrote:
> I have 3 models, Group, User, Referral. Group hasMany User, User
> hasMany File.
>
> I have some Users that I want to be able to see all Files for other
> Users in their Group. Right now I'm trying to do this with
> $users = $this->User->findAll('group_id = ' . $User['group_id']);
> $this->File->findAll(array('File.user_id' => $users));
Hi Brian,
$constraint = array(
'User.group_id'=>$User['group_id'],
'NOT' => array('User.id' => $User['id'])
);
//EITHER:
$this->User->displayField = 'id';
$users = $this->User->generateList($constraint);
//OR
$users = $this->User-
>generateList($constraint,null,null,null,'{n}.User.id');
//FOLLOWED BY
$data = $this->File->findAll(array('File.user_id' => $users));
//pr ($data); die;
> Obviously this isn't working. The $users array is in the wrong format
> for use in a conditions statement (even if I restrict it to grabbing
> id only in the first findAll.) Am I expecting to much here or simply
> going about this the wrong way?
I'll go for option 2. :D.
hth,
AD
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---