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,
));
}
Page 1 of 1
Add Condition problem
#2
Posted 25 March 2010 - 10:19 AM
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:
Also you can do the same thing by doing:
$criteria->compare('telephone', $_GET['tel'], true);
#3
Posted 25 March 2010 - 10:21 AM
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):
and assuming you're on a MySQL backend, you also need to use quotations when comparing strings, so it's actually going to be
otherwise it will look for a column name that matches your $_GET['tel']% string.
Neel, on 25 March 2010 - 09:48 AM, said:
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,
));
}
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,
));
}
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.
Dana Luther
Sr. Developer at Envisage International
D.H. Luther - Web Design & Development
Dana's Yii Blog
Extensions:
ChildrenRequiredValidator | ESitemap | EStrongPassword | ES3
Sr. Developer at Envisage International
D.H. Luther - Web Design & Development
Dana's Yii Blog
Extensions:
ChildrenRequiredValidator | ESitemap | EStrongPassword | ES3
Share this topic:
Page 1 of 1

Help













