我有这样的代码
$this->Customer->setSource('customer');
$this->Customer->find('first',array('fields'=>" IF(assigned_id.assigned_id is NULL,
CONCAT(GROUP_CONCAT(DISTINCT(`team_members`.`user_id`)),'=>TEAM')"));
我需要的输出是这个
SELECT IF(assigned_id.assigned_id is NULL, CONCAT(GROUP_CONCAT(DISTINCT(`team_members`.`user_id`)),'=>TEAM') FROM `ctk_customer` AS `Customer` WHERE 1 = 1 LIMIT 1
但是我得到了这个输出
SELECT DISTINCT IF(assigned_id.assigned_id is NULL, CONCAT(GROUP_CONCAT(DISTINCT(`team_members`.`user_id`)),'=>TEAM') FROM `ctk_customer` AS `Customer` WHERE 1 = 1 LIMIT 1
答案 0 :(得分:2)
$this->Customer->setSource('customer');
$this->Customer->find('first',array('fields'=>" IF(assigned_id.assigned_id is NULL,
CONCAT(GROUP_CONCAT(distinct(`team_members`.`user_id`)),'=>TEAM')"));
答案 1 :(得分:0)
it looks like你可以这样做:
array(
'conditions' => array('Model.field' => $thisValue), //array of conditions
'recursive' => 1, //int
'fields' => array('Model.field1', 'DISTINCT Model.field2'), //array of field names
'order' => array('Model.created', 'Model.field3 DESC'), //string or array defining order
'group' => array('Model.field'), //fields to GROUP BY
'limit' => n, //int
'page' => n, //int
'offset'=>n, //int
'callbacks' => true //other possible values are false, 'before', 'after'
)