CDbCriteria addSearchCondition LIKE%

Hi guys,

I’ve a question.

When I use


it uses the LIKE in this way (suppose that $_GET[‘name’] is equal to “example”)

SELECT .. FROM .. WHERE name LIKE '%example%'

But if want it o be only

LIKE 'example%'



how can I do?

thank you

$criteria->addSearchCondition(‘name’,’%’.$_GET[‘name’], false);

Last param is boolean $escape, whether the keyword should be escaped if it contains characters % or _.

Please check

And there is also the method ‘compare’ which is just below in the documentation.

Set ‘partialMatch’ to true, or set $escape to false [partialMatch is preferable in principle].