Not really sure if it would work but you can try this

$this->Shift->find('all', array(
    'contain' => array(
        'Assignment' => array(

));

On Jun 4, 11:29 am, shantamg <jason.galu...@gmail.com> wrote:
> yes, that about does it.. but what if i want to order by two fields?
> something like: Person.category_id asc, Person.name asc
>
> On Jun 2, 12:21 am, vekija <vedran.konto...@gmail.com> wrote:
>
>
>
> > Not sure if I understood the question, but if you want Alix to appear
> > before Shantam you can sort the assignment array with Set::sort
>
> > Assuming your data array is called $shifts, you could do it like this
>
> > foreach($shifts as $i => $shift) {
> >   $shifts[$i]['Assignment'] = Set::sort($data['Assignment'],
> > '{n}.Person.name', 'asc');
>
> > }
>
> > On Jun 2, 5:52 am, shantamg <jason.galu...@gmail.com> wrote:
>
> > > Shift hasMany Assignment
> > > Assignment belongsTo Person, Shift
> > > Person hasMany Assignment
>
> > > So if I do this:
>
> > > $this->Shift->find('all', array(
> > >     'contain' => 'Assignment.Person'
> > > ));
>
> > > I get something like this:
>
> > > Array
> > > (
> > >     [0] => Array
> > >         (
> > >             [Shift] => Array
> > >                 (
> > >                     [id] => 1
> > >                     etc...
> > >             [Assignment] => Array
> > >                 (
> > >                     [0] => Array
> > >                         (
> > >                             [id] => 1
> > >                             [person_id] => 1
> > >                             [shift_id] => 1
> > >                             etc...
> > >                             [Person] => Array
> > >                                 (
> > >                                     [id] => 1
> > >                                     [name] => Shantam
> > >                                     etc...
> > >                                 )
> > >                         )
> > >                     [1] => Array
> > >                         (
> > >                             [id] => 2
> > >                             [person_id] => 2
> > >                             [shift_id] => 1
> > >                             etc...
> > >                             [Person] => Array
> > >                                 (
> > >                                     [id] => 2
> > >                                     [name] => Alix
> > >                                     etc...
> > >                                 )
> > >                         )
> > >                     etc....
> > >                 )
> > >         )
> > > )
>
> > > So there's only ever one Person per Assignment. How can I order the
> > > Assignments by Person.name?
>
> > > Thanks,
> > > Jason

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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