“怎么说?”;独特的;cakephp查询中的关键字?
我有这样的代码“怎么说?”;独特的;cakephp查询中的关键字?,cakephp,Cakephp,我有这样的代码 $this->Customer->setSource('customer'); $this->Customer->find('first',array('fields'=>" IF(assigned_id.assigned_id is NULL, CONCAT(GROUP_CONCAT(DISTINCT(`team_members`.`user
$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
你可以这样做:
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'
)
您可以尝试使用find('all')
i尝试了find('all')、find('count')。但是如果(分配的id.assigned的id你是说那里只分配了一个id,结果就错了吗?
$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')"));