CakePhp太多相同的查询

时间:2016-04-12 13:58:44

标签: cakephp-2.0

我有一个复杂的模型,有很多可包含的。 但是,当我运行查询时,我在日志中看到许多类似的查询:

SELECT `Company`.`id` FROM `u`.`companies` AS `Company` LEFT JOIN `u`.`companies` AS `Parent` ON (`Company`.`parent_id` = `Parent`.`id`) LEFT JOIN `u`.`groups` AS `Group` ON (`Company`.`group_id` = `Group`.`id`) WHERE 1 = 1 GROUP BY `Company`.`id` LIMIT 30
SELECT `Group`.`id`, `Group`.`name`, `Group`.`alias`, `Group`.`label` FROM ``.`groups` AS `Group` WHERE `Group`.`id` = 1     
SELECT `Group`.`id`, `Group`.`name`, `Group`.`alias`, `Group`.`label` FROM `u`.`groups` AS `Group` WHERE `Group`.`id` = 4    
SELECT `Group`.`id`, `Group`.`name`, `Group`.`alias`, `Group`.`label` FROM `u`.`groups` AS `Group` WHERE `Group`.`id` = 1       
SELECT `Group`.`id`, `Group`.`name`, `Group`.`alias`, `Group`.`label` FROM `u`.`groups` AS `Group` WHERE `Group`.`id` = 1       
SELECT `Group`.`id`, `Group`.`name`, `Group`.`alias`, `Group`.`label` FROM `u`.`groups` AS `Group` WHERE `Group`.`id` = 1

为什么会有这么多相同的查询? 我的查询非常简单:

$this->paginate = array(
    'Company' => array(
      'contain' =>array(     
        'Group',
        'Parent' => array(
            'fields' => array('ragione')
        ),
        'Parent.Group'
    ),
    'limit' => 30,
    'group' => array('Company.id'),
    'conditions' => $conditions,
    'order' => array('Company.created ASC')
    )
); 

0 个答案:

没有答案