Wednesday, March 3, 2010

Re: Containable empty model

Contain is great when viewing a record and pulling all it's related
data no matter how deep as it runs separate queries and then
conveniently combines them back into one nicely structured array.

However, if your paginating and want to include conditions on a deeply
associated model then you need to use on-the-fly associations
(bindModel/unbindModel) to force joins making sure the models you need
to place conditions on are included in the main query call.

I'm not sure why cake returning an empty array is a problem to you, in
the view you simply check if !empty($this->data['ModelName']) and do
or don't traverse that array.

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: