queej
(Dqj)
September 6, 2010, 12:09am
1
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 );
}
Thanks.
queej
(Dqj)
September 6, 2010, 12:12am
2
Of course I figured it out right after giving up and posting here:
$criteria->compare('LOWER(title)',strtolower($this->title),true);
wonk4rol
(Andedi Foss)
May 18, 2012, 7:14am
3
queej:
Of course I figured it out right after giving up and posting here:
$criteria->compare('LOWER(title)',strtolower($this->title),true);
Thanx guys, it works for me.I implemnt it to my CGridView
mdomba
(Maurizio Domba Cerin)
May 18, 2012, 9:12am
4
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 ‘_’.
rayat2010
(Morshed Usa)
January 17, 2017, 6:46pm
6
For Oracle DB: The following method is worked:
$criteria->compare(‘LOWER(NAME)’,strtolower($this->NAME),true,‘AND’, ‘LIKE’);
Thank you