Problem with CDBCriteria

My example is as follows:

$q = ‘test search’;

$criteria = new CDbCriteria;

$criteria->condition = “question.title LIKE ‘%:query%’ OR t1.content LIKE ‘%:query%’”;

$criteria->params = array(’:query’=>$q);

For some reason the :query param never gets converted to the value of $q!

Am I doing something wrong?

Please help!

I did something like that:


		$criteria->condition = 'userID NOT IN (:users) AND deletedDate IS NULL';

		$criteria->params	 = array(':users'=>implode(",",$list)); // write the value in array



Try writing the value like that:


$criteria->params = array(':query'=>'value here');

Maybe it helps. Just try.




$criteria->condition = "question.title LIKE :query OR t1.content LIKE :query";

$criteria->params = array(':query'=>'%'.$q.'%');



I have played with it a lot to get it work…


$items = $this->findAll("name LIKE :query", array(':query'=>'%'.$s.'%'));

One thing, in debug info we get displayed:


SELECT * FROM `category` WHERE name LIKE :query

so :query is not replaced by our query (as I thought)

Madz, what if you add this to your ‘db’ component in config?




  'enableParamLogging'=>true,



/Tommy