Your code looks correct. Does your comments model have the user
relation defined?

On Oct 8, 6:41 pm, broxi <[email protected]> wrote:
> I cant seem to get this to work, here is the code:
>
> $post = $this->Post->find('first', array(
>                                     'conditions' => array(
>                                         'Post.id' => $id
>                                     ),
>                                     'contain' => array(
>                                         'Category',
>                                         'User',
>                                         'Comment' => array(
>                                             'User'
>                                             )
>                                         )
>                                     )
>                         );
>
> it gets all the required info the same as using recursive=1 but doesnt
> get the User data associated with the comments.
>
> any ideas
> Thanks.
>
> On Oct 9, 1:24 am, broxi <[email protected]> wrote:
>
> > Thanks for the reply, I will look into that
>
> > Later
> > Broxi
>
> > On Oct 8, 7:54 pm, Miles J <[email protected]> wrote:
>
> > > Ditch the recursion and use the Containable behavior.
>
> > >http://book.cakephp.org/view/474/Containable
>
> > > On Oct 8, 9:52 am, broxi <[email protected]> wrote:
>
> > > > Hi all,
>
> > > > I am a toatl noob with cakephp, i am trying to build a blog and i feel
> > > > that i am progresing quite well. I just have one question...
>
> > > > I currently have 4 models (post, user, comment, catgeory), when
> > > > reading a post from the database with recursive=0 i only get the
> > > > post,user and category data, using recursive=1 i get the comment info
> > > > too but i also want to get the user info for each comment aswell.
> > > > switching to recursive=2 does this but doubles the query count and
> > > > duplicating some of the queries.
>
> > > > Can you offer any advice on a better, more efficient way to do this.
>
> > > > Thanks for your help
>
> > > > Broxi
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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