Monday, January 31, 2011

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

Here is the model for Category:
var $hasAndBelongsToMany = array(
'Product' => array(
'className' => 'Product',
'joinTable' => 'categories_products',
'foreignKey' => 'category_id',
'associationForeignKey' => 'product_id'
)
);
var $belongsTo = array(
'Parent' => array(
'className' => 'Category',
'foreignKey' => 'parent_id'
)
);

Here is the model for Product:
var $hasMany = array(
'Variation' => array(
'className' => 'Variation',
'foreignKey' => 'product_id',
'dependent' => false,
)
);

I think it's pretty straightforward. There are 32 categories, 86
products and 115 variations. Looks like it's doing a database call for
each variation.

--
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: