$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);
cakephp 中连接查询多表 或group by,布布扣,bubuko.com
原文:http://www.cnblogs.com/chenkg/p/3821004.html