Wednesday, June 2, 2010

Re: Containable() not working for $this->Model1->Model2->find('', array('contain') => 'Model3');

Ok, so what you want is:
1) The article;
2) The related comments;
3) The related comment ranks for each comment.

[code]
$this->Article->Comment->find(
'threaded',
array(
'contain' => array('Article', 'CommentRank'),
'conditions' => array('Comment.article_id' => $id)
)
);
[/code]
That should give you the comments in a threaded format, with the
article and comment rank attached.

Enjoy,
John

On Jun 2, 4:01 pm, Shaz <shazam...@gmail.com> wrote:
> $this->Article->Comment->find(
>     'threaded',
>     array(
>         'contain' => array('CommentRank'),
>         'conditions' => array('Article.id' => $id)
>     )
> );
>
> ^^ Sorry it was a typo in the post; the code above is from my
> application. It does return an Array but doesn't use the containable
> behavior; but it works when I do:
> $this->Article->find(
>     'threaded',
>     array(
>         'contain' => array('Comment'),
>         'conditions' => array('Article.id' => $id)
>     )
> );
>
> Limiting the results to just the Article and its Comments; what I want
> is the Article, Comments and the Comment Ranks.
>
> I've checked the associations again and they all look fine - they
> provide results when doing $this->model1->model2->find() but don't
> like to use the containable behaviour...
>
[snip]

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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: