DISTINCT字段不会显示在cakephp 1.3

时间:2016-09-12 22:03:09

标签: php cakephp cakephp-1.3

我正在运行提要表,我不希望检索带有“NULL”的DISTINCT字段。

$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谢谢。

1 个答案:

答案 0 :(得分:0)

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

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