Saturday, October 31, 2009

Re: Containable behaviour doesn't return all data

Yes I try to get all the users of the team with id=4 but I don't get
anything.
Where do i mistake?

On 30 Ott, 20:42, John Andersen <j.andersen...@gmail.com> wrote:
> You are using find('first', $options), so you only get one record!
> And the one record will be the one which has a team with a user!
> You don't get the team!
>
> I am guessing - are you trying to get all the users in the first team
> for the specified user?
> Enjoy,
>    John
>
> On Oct 30, 6:30 pm, "marco.rizze...@gmail.com"
>
> <marco.rizze...@gmail.com> wrote:
> > Hi
> > I use containable behaviour, but I don't get all data that I have
> > requested
> > My code is :
>
> >                 $options['fields'] = array('User.*');
> >                 $options['conditions'] = array('User.username' => $user_id);
> >                 $options['contain'] = array(
> >                         'Organization' => array(
> >                                 'fields'=>array('Team.*'),
> >                                 'User' => array(
> >                                         'fields' => array('User.*')
> >                                 )
> >                         )
> >                 );
> >                 pr($this->User->find('first',$options));
>
> > But I get only :
>
> > Array
> > (
> >     [User] => Array
> >         (
> >             [id] => 1
> >             .......
> >             .......
> >         )
>
> >     [Team] => Array
> >         (
> >             [0] => Array
> >                 (
> >                     [id] => 4
> >                     .......
> >                     .......
> >                     [UsersTeams] => Array
> >                         (
> >                             [id] => 1
> >                             [user_id] => 1
> >                             [team_id] => 4
> >                         )
> >                 )
> >         )
> > )
>
> > I don't get all users that are inside team
>
> > Between User and Team there is a hasAndBelongsToMany relation.
>
> > How can I do to get also all users that are in team?
>
> > Many Thanks
> > Marco
>
>
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: