How do add LIKE with addSearchCondition

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?

Just remove "LIKE" in the first parameter…



Ah, it automatically knows because it is a text field, nice! Many thanks!

another way:


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’