Hi, I've got the same problem Hope someone can help
Thanks ! Jérémie On 11 mai, 18:50, Astro <[email protected]> wrote: > I have a problem whith Cake PHP generating duplicate mysql queries > when using 'contain' with find(). > > In the controller: > > $data = $this->Client->find('first',aa( > 'conditions',aa( > 'Client.id',$id > ), > 'contain',array( > 'Country', > 'Sale'=>array('User','Product','ProductGroup') > ) > )); > > It fetches all data I want, but generates the same queries again if > for instance different Sales have the same ProductGroup. Here is what > the mysql debug says: > > 37 SELECT `ProductGroup`.`id`, `ProductGroup`.`name`, > `ProductGroup`.`description`, `ProductGroup`.`price_per_month`, > `ProductGroup`.`price_one_time`, `ProductGroup`.`period`, > `ProductGroup`.`created`, `ProductGroup`.`modified` FROM > `product_groups` AS `ProductGroup` WHERE `ProductGroup`.`id` = 6 > 38 SELECT `ProductGroup`.`id`, `ProductGroup`.`name`, > `ProductGroup`.`description`, `ProductGroup`.`price_per_month`, > `ProductGroup`.`price_one_time`, `ProductGroup`.`period`, > `ProductGroup`.`created`, `ProductGroup`.`modified` FROM > `product_groups` AS `ProductGroup` WHERE `ProductGroup`.`id` = 6 > 39 SELECT `ProductGroup`.`id`, `ProductGroup`.`name`, > `ProductGroup`.`description`, `ProductGroup`.`price_per_month`, > `ProductGroup`.`price_one_time`, `ProductGroup`.`period`, > `ProductGroup`.`created`, `ProductGroup`.`modified` FROM > `product_groups` AS `ProductGroup` WHERE `ProductGroup`.`id` = 6 > 40 SELECT `ProductGroup`.`id`, `ProductGroup`.`name`, > `ProductGroup`.`description`, `ProductGroup`.`price_per_month`, > `ProductGroup`.`price_one_time`, `ProductGroup`.`period`, > `ProductGroup`.`created`, `ProductGroup`.`modified` FROM > `product_groups` AS `ProductGroup` WHERE `ProductGroup`.`id` = 6 > > Any ideas to optimize this? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
