2016-09-12 40 views
0

我正在运行feeds表,我不希望带有“NULL”的DISTINCT字段检索。DISTINCT字段不显示在cakephp 1.3中

$this->Feed->recursive = 0; 
$this->paginate = array('Feed' => array(
'limit' => 6, 
'fields' => 'DISTINCT Feed.* IS NOT NULL', 
'conditions' => array('Feed.member_id' => $friends_ids), 
'order' => array('Feed.created' => 'DESC'), 
)); 
$notes = $this->paginate('Feed'); 
$this->set('notes', $notes); 

// debug($notes); 
unset($notes); 

这给了我一个错误。警告(512):SQL错误:1054:未知列'Feed。* IS NOT NULL'。在cakephp上运行这个1.3谢谢。

+0

它应该是一个条件,而不是字段? – Prisoner

+0

顺便说一句:当你使用DISTINCT与分页,计数()返回不正确的值,请参阅:https://github.com/cakephp/cakephp/issues/8778 – kicaj

回答

0

尝试将NULL检查移动到条件数组。

'fields' => 'DISTINCT Feed.*', 
'conditions' => array(
    'Feed.member_id' => $friends_ids, 
    'Feed.the_field_to_check IS NOT NULL' 
),