Hi Nick,

Thanks for the reply.

Sorry I should have said in my original post - I'm already using Containable
AND setting recursive to -1 in app_model.php.

But still the selects are incredibly inefficient - a single query to fetch
each individual row?!

I'm not specifying 'fields' but surely that's not going to mean the
difference between what should be 2 queries at most, and the thousands I'm
ending up with...

Thanks,

Alex

On Tue, Jul 13, 2010 at 9:59 AM, nurvzy <nur...@gmail.com> wrote:

> Use a mixture of:
>
> fields option key (so you're not retrieving data you don't intend to
> use),
> containable (so you're not selecting associative models and their
> fields you don't care about),
> and set recursive = -1 in your app_model.php
>
> The first thing I do whenever I start any new CakePHP project is open
> up app_model.php and add actsAs = array('Containable') and recursive =
> -1.
>
> I suggest you take advantage of the containable component.  Read about
> it here:
> http://book.cakephp.org/view/474/Containable
>
> Hope that helps,
> Nick
>
> On Jul 13, 2:35 am, Alex Bovey <a...@bovey.co.uk> wrote:
> > Hi all,
> >
> > Using Cake 1.2.0.6311 I'm having real problems with the number of SQL
> > queries in my app.
> >
> > For example, I have Enquiry belongsTo User and User hasMany Enquiry.
> >
> > A simple $this->Enquiry->find('all') results in one query to fetch the
> > enquiries, and then a separate query for every single Enquiry to fetch
> the
> > User for that Enquiry.
> >
> > When I have more complex model relations I'm ending up with over 10,000
> SQL
> > queries.
> >
> > What am I doing wrong?!
> >
> > Thanks,
> >
> > Alex
>
> 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+unsubscr...@googlegroups.com<cake-php%2bunsubscr...@googlegroups.com>For
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>



-- 
Alex Bovey
Web Developer | Alex Bovey Consultancy Ltd
Registered in England & Wales no. 6471391 | VAT no. 934 8959 65
a...@bovey.co.uk | t 0844 567 8995 | m 07828 649386 | f 0870 288 9533
PHP | MySQL | AJAX | XHTML | CSS | Javascript | XML | W3C Accessibility

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

Reply via email to