2016-09-12 22 views
0

"NULL"이 포함 된 DISTINCT 필드를 검색하지 않으려는 피드 테이블을 실행 중입니다.cakephp 1.3에 표시되지 않는 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 : 알 수없는 열 '피드. * IS NOT NULL'입니다. 이것을 cakephp 1.3에서 실행합니다. 고마워요.

+0

필드 대신 조건이어야합니까? – Prisoner

+0

BTW : 페이지 매김에 DISTINCT를 사용하면 count()가 잘못된 값을 반환합니다. 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' 
),