试试这个
$this->paginate = array( 'limit'=>5, 'order'=>'Note.datetime DESC', 'conditions' => array( 'Note.status'=>1, 'OR' => array( "MATCH(Note.title) AGAINST('".$q."' IN BOOLEAN MODE)", "MATCH(Note.content) AGAINST('".$q."' IN BOOLEAN MODE)" ) ) );
换句话说,用引号括起搜索条件
编辑ndm的建议是有道理的
$this->paginate = array( 'limit'=>5, 'order'=>'Note.datetime DESC', 'conditions' => array( 'Note.status'=>1, 'OR' => array( 'MATCH(Note.title) AGAINST(? IN BOOLEAN MODE)' => $q, 'MATCH(Note.content) AGAINST(? IN BOOLEAN MODE)' => $q ) ) );
你也可以试试这个:
$this->paginate = array( 'limit'=>5, 'order'=>'Note.datetime DESC', 'conditions' => array( 'Note.status'=>1, 'OR' => array( 'Note.title LIKE' => "%$q%", 'Note.content LIKE' => "%$q%" ) ) );