2016-09-12 69 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' 
),