首页 > 代码库 > cakephp 中连接查询多表 或group by

cakephp 中连接查询多表 或group by

 $options = array(                    ‘conditions‘ => $conditions,                    ‘fields‘=>array(‘Category.*‘,‘COUNT(`Entity`.`id`) as `entity_count`‘),                    ‘joins‘ => array(‘LEFT JOIN `entities` AS Entity ON `Entity`.`category_id` = `Category`.`id`‘),                    ‘group‘ => ‘`Category`.`id`‘,                    ‘contain‘ => array(‘Domain‘ => array(‘fields‘ => array(‘title‘)))                );                return $this->find(‘all‘, $options);