Wednesday, March 3, 2010

Re: Containable empty model

Thanks for the reply. I guess I'm trying to do too much with contain.

I tend to be too much on the finicky and efficient side of things.
This is why I prefer no record to one with an empty array. Also it
makes my unit tests easier since I can test the model. I guess I
should change back to the on-the-fly associations. Thats probably what
htey're there for.

Thanks again

On Mar 3, 10:19 am, WebbedIT <p...@webbedit.co.uk> wrote:
> 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: