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);

posted on 2014-07-02 19:06  陈可  阅读(543)  评论(0编辑  收藏  举报

导航