Wednesday, June 2, 2010

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

$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...

On 1 June, 18:30, John Andersen <j.andersen...@gmail.com> wrote:
> I do hope it is only a typo in the post and not in your code!
>
> [code]
> $this->Model1->Model2->find(
>    'threaded',
>    array('contain' => 'Model3')
> );
> [/code]
>
> Is the above what is not working?
> Have you checked that an association/relationship is defined between
> Model2 and Model3?
> Enjoy,
>    John
>
> On Jun 1, 8:14 pm, Shaz <shazam...@gmail.com> wrote:
>
> > I'm trying to avoid putting $uses at the top of my controller and
> > aiming to make do with model associations, but alas containable()
> > doesn't work when trying:
>
> > $this->Model1->Model2->find('threaded', array('contain') => 'Model3');
>
> > But:
>
> >  $this->Model1->find('threaded', array('contain') => 'Model2.Model3');
>
> > Provides me a threaded result, containable works, but the find results
> > not in the array structure I want (using parent_id to make threaded
> > comments)...

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: