forbin
(Inquiry)
May 28, 2010, 12:06am
1
I am trying to search a field for keywords and I am generating the criteria with addSearchCondition. I currently have it like this
$criteria->addSearchCondition('question LIKE',$_POST['search']);
This is producing a SQL error. I cannot see the generated query and I can find no documentation on how to do this with addSearchCondition. Any help?
komodo
(J Theill)
May 28, 2010, 12:32am
2
Just remove "LIKE" in the first parameter…
$criteria->addSearchCondition('question',$_POST['search']);
Documentation
forbin
(Inquiry)
May 28, 2010, 2:46am
3
Ah, it automatically knows because it is a text field, nice! Many thanks!
another way:
$criteria->compare('question',$_POST['search'],true);
komodo
(J Theill)
May 28, 2010, 5:08am
5
Not actually… If you take a look at the Documentation, you would see that the function takes 5 parameters and the last three of them are optional. The fifth parameter is the like-keyword and defaults to ‘LIKE’