Friday, June 18, 2010

Re: efficiency vs conforming to standards

$this->User->Photo->find() perhaps?

From my understanding we should use the model associations (which
provide an efficient sql query if i remember correctly) first to see
if it gives us what we want, otherwise use findall/contain.

On Jun 18, 7:21 am, "Alan Asher" <a...@asteriskpound.com> wrote:
> I have a users model and a photos model,
>
> Class users{
>
> Var belongsto=array(
>
>    'Photos'
>
> }
>
> You get the idea,
>
> When I run a $this->Some
> Model>find('all',array('contain'=>array('User','User.Photo')))
>
> It breaks this up into 2 sql statements so even with a limited amount of 20
> results, there's a lot of redundancy and it costs time and processing.  I'm
> about to rewrite all my inefficient finds into queries that have my own
> custom joins.  
>
> Does anyone have suggestions how to get the photos table to show up in the
> results without cake making a separate query?
>
> Alan

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate