1

我有这样的代码

$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 
4

2 回答 2

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')"));
于 2012-09-03T14:21:18.713 回答
0

看起来你可以这样做:

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'
)
于 2012-09-03T13:04:36.227 回答