edanb
(Edanbarak)
August 25, 2009, 3:26pm
1
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.
pestaa
(Pestaa)
August 25, 2009, 4:37pm
3
$criteria->condition = "question.title LIKE :query OR t1.content LIKE :query";
$criteria->params = array(':query'=>'%'.$q.'%');
madz
(Madman)
October 9, 2009, 1:43pm
4
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)
tri
(tri - Tommy Riboe)
October 9, 2009, 4:28pm
5
Madz, what if you add this to your ‘db’ component in config?
'enableParamLogging'=>true,
/Tommy