CDbCriteria と CActiveDataProvider でこのクエリを実行するにはどうすればよいですか?
'SELECT * FROM tbl_post where title LIKE %'.$title.'% ORDER BY title LIKE '.$title.' DESC , title LIKE '.$title.'% DESC'
更新: 最後に私はこれを書きました:
$criteria = new CDbCriteria;
$criteria->addCondition('title LIKE :title');
$criteria->params = array(':title'=>'%'.$title.'%',':t1'=>$title,':t2'=>$title.'%');;
$criteria->order='title LIKE :t1 DESC , title LIKE :t2 DESC';
しかし、私はエラーが発生しました:
CDbCommand failed to execute the SQL statement: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens. The SQL statement executed was: SELECT COUNT(*) FROM `tbl_post` `t` WHERE title LIKE :title