Case Insensitive Search

Something I thought would be trivial in Yii (because it handles so many things so well) is case insensitive searching. Is there anything I can do to make the following code use an ILIKE instead of a LIKE?

public function search() {

    $criteria = new CDbCriteria;

    $criteria->compare( 'title', $this->title, true );



Of course I figured it out right after giving up and posting here:


Thanx guys, it works for me.I implemnt it to my CGridView

To really use ILIKE (postgress)… you can use:

$criteria->addSearchCondition('title', $this->title, true, 'AND', 'ILIKE');

Below adjustment will give you more results if user uses characters like ‘%’ and ‘_’:

$criteria->addSearchCondition('title', '%'.$this->title.'%', false, 'AND', 'ILIKE');

Otherwise you will get empty results if user uses characters like ‘%’ and ‘_’.

For Oracle DB: The following method is worked:

$criteria->compare(‘LOWER(NAME)’,strtolower($this->NAME),true,‘AND’, ‘LIKE’);

Thank you