MySql then text searches by default are case insensitive. PostgreSQL I think you have to force it to lower.
I don't see anything in the API though for doing this, but you can control it in the MySql settings of laravel, again not sure about PostgreSQL
utf8_bin (default) case-insensitive
unicode_ci case-sensitive
Not sure how to go about it on a query by query basis though. I would suspect you need raw selects
DB:select('select * from table where lower(field) like "%?%"', array($value))
Thank you for your kind answer. I have not find relevant information either (not in the Laravel files either).
For obvious reasons I don't want to mess with the default case sensitivity. This was my solution, which is almost the same as yours:
$q->where( function ( $q2 ) use ( $stext ) {
$q2->whereRaw( 'LOWER(`title`) like ?', array( $stext ) );
$q2->orWhereRaw( 'LOWER(`desc`) like ?', array( $stext ) );
});
Maybe is too late, but if you don't want to use "LOWER", you could use "ILIKE". But it stills working at PostgresSql only.
$q->where( function ( $q2 ) use ( $stext ) {
$q2->where( 'title', 'ilike', "%$stext%" ) );
$q2->orWhere('desc', 'ilike', "%$stext%" ) );
});
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community