我使用zend框架,不能在模型中编写下一个sql查询:
SELECT `id_user`,`system_role`,count(`system_role`)
FROM `favorites`
group by `id_user`,`system_role`
怎么做?
答案 0 :(得分:3)
$db = new Zend_Db_Table('favorites');
$select = $db->select()
->from('favorites', array('id_user', 'system_role', 'COUNT(system_role)'))
->group('id_user', 'system_role');