I was trying to see if there was a way to do it within cake without a
ton of iteration, but so far it appears that I'm going to have to do
some data cleanup one way or another.  $recursive = 2 would retrieve
all the data, but wouldn't allow it to be sorted directly, I would
have to go iterate over the Group->User array adding each of thier
File parts into a global array and then sort that.  I kinda thought I
was going to have to clean up the data (as suggested by Langdon),
really just wondering if there was a "cleaner" way to do it I guess.

I actually got the idea for the findAll() to findAll() search from
reading the manual on Models and conditions in particular when I first
realized this was going to be an issue.

-- Brian

On May 22, 10:03 pm, Joshua McFarren <[EMAIL PROTECTED]> wrote:
> Set $recursive = 2 in your Group model. See the manual.
>
> On May 22, 9:18 pm, Langdon Stevenson <[EMAIL PROTECTED]>
> wrote:
>
> > Hi Brian
>
> > Have a look at the Conditions section of the Model page in the manual.
> > It will give you a thorough explanation of how to construct the kind of
> > complex conditions statement that you want (hint, this would use an SQL
> > "IN" condition - which the manual covers).
>
> > Given what you are trying to do I expect that you will have to rework it
> > to get the right structure to use in the conditions.  There may be an
> > automagical way in Cake to convert a result set to a conditions array,
> > but I don't know it.  I just loop over the array and reform the data the
> > way that I need it.
>
> > Regards,
> > Langdon
>
> > Brian Hartvigsen 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));
>
> > > 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?


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

Reply via email to