Hello,
I want to use SQL LIKE condition, can you help me? I tried this way but not working
$criteria->addCondition(‘Telephone LIKE %’.$_GET[Telephone].’%’);
Hello,
I want to use SQL LIKE condition, can you help me? I tried this way but not working
$criteria->addCondition(‘Telephone LIKE %’.$_GET[Telephone].’%’);
Try this method: http://www.yiiframework.com/doc/api/1.1/CDbCriteria#addSearchCondition-detail
And this is exactly what you need: http://www.yiiframework.com/forum/index.php?/topic/9519-how-do-add-like-with-addsearchcondition/
I try both
$criteria->addSearchCondition(‘tn’,$_GET[‘tn’]);
and
$criteria->compare(‘tn’,$_POST[‘tn’],true);
But get my results and extra two results
3042030998
3042030999
9043042030
9043042031
I am looking first 6 digit match like this "3042030"
That’s the two different conditions.
Try this way for condition "LIKE tn%" (not "LIKE %tn%"):
$criteria->addCondition('tn LIKE :tn');
$criteria->params[':tn']=$_GET['tn'].'%';
Thank, working