Monday, January 31, 2011

Re: Containable Query Slow - Am I doing it wrong?

i think (i'm not sure), but in contain key you should not use 'fields', 'conditions' and so on keys, because this you should do when you make a model associations, so you should do just this

{{{

$this->Category->Behaviors->attach('Containable');
$tempCategories = $this->Category->find('all', array(
       'fields' => array('id','title','description','order'),
       'order' => array("Parent.title" => "asc","Category.order" => "asc"),
       'contain'=>array(
               'Parent' ,
               'Product' => array(
                  'Variation'
               )             
        )
));

}}}

but like i said....i'm NOT sure....


--
Lep pozdrav, Tilen Majerle



2011/1/31 TimG <tim@gurske.com>
Hey,
This code below works well but the query is really slow. It adds five
seconds more to the page request time. Am I doing something wrong or
is it just the way it is? Also, is there a way to do this with a
custom query and would it be any quicker? Thanks in advance!

$this->Category->Behaviors->attach('Containable');
$tempCategories = $this->Category->find('all', array(
       'fields' => array('id','title','description','order'),
       'order' => array("Parent.title" => "asc","Category.order" => "asc"),
       'contain'=>array(
               'Parent' => array('fields' => array('id','title','description')),
               'Product' => array('fields' => array('id','title','description'),
                       'conditions' => array('active'=>1),
                       'Variation' => array('fields' => array('id','title','price'))
))));

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


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

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
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

No comments: