neel
(Kazi Neel)
1
Hey Guys
I have one problem .
$criteria->addCondition(‘telephone LIKE’. $_GET[‘tel’]. ‘%’);
this addCondition is not working
public function view()
{
$criteria=new CDbCriteria;
$criteria->addCondition('telephone LIKE'. $_GET['tel']. '%');
return new CActiveDataProvider('Contact', array(
'criteria'=>$criteria,
));
}
lgoss007
(Lgoss007)
2
Looks like there is no space between LIKE and the value… is there? Are you debugging the output?
Also you can do the same thing by doing:
$criteria->compare('telephone', $_GET['tel'], true);
Pardon me if this is just a transcription error in pasting here, but it looks like you have a whitespace/quotes error in your condition:
should read as (note the space after LIKE):
$criteria->addCondition('telephone LIKE '. $_GET['tel']. '%');
and assuming you’re on a MySQL backend, you also need to use quotations when comparing strings, so it’s actually going to be
$criteria->addCondition('telephone LIKE `'. $_GET['tel']. '%`');
otherwise it will look for a column name that matches your $_GET[‘tel’]% string.
neel
(Kazi Neel)
4
I want to match first 6 digit. is that possible