You just need to set recursive to 2.

On Sep 9, 8:20 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hello newsgroup!
>
> I have defined the following associations in my models:
> PostModel:  "Post _hasMany_ Comments"
>
> var $hasMany = array(
>   'Comment' => array(
>     'className' => 'Comment',
>     'conditions' => '',
>     'foreignKey' => 'post_id',
>   )
> );
>
> CommentModel:  "Comment _belongsTo_ User"
>
> var $belongsTo = array(
>   'User' => array(
>     'className' => 'User',
>     'conditions' => '',
>     'foreignKey' => 'user_id'
>   )
> );
>
> When I use the query $this->Post->find(), cakephp only uses the
> associations in the PostModel (this is ok).
> This works for simple requests like $this->Post->find() and it returns
> the data array:
> array(
>   'Post' => array(...),
>   'Comment' => array(...)
> )
>
> But is it also possible to include the second association "Comment
> _belongsTo_ User" into the query $this->Post->find()?
> How do I have to define this or other associations in my Post-Model to
> get a data array like this:
> array(
>   'Post' => array(...),
>   'Comment' => array(
>     'User' => array(...)
>   )
> )
>
> I have tried many possibilities in the Post model... still the same
> results!
> The version I used now is a foreach(), which finds all Users for the
> returned Comments of $this->Post->find().
> ...this makes my CakeApp a little bit slow! Any ideas for a faster
> association?
>
> Many thanks for your answers!
>
> derlippe
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to