mercredi 22 août 2018

Eloquent where lower() LIKE with PostgrSQL Laravel

I wanna speed up my queries in PostgreSQL in Laravel with Eloquent.

Now I have this:

$word = 'Bertha'
$cows->where('name', 'ilike', '%' . $word . '%');

Which can be faster when I do a normal like instead of ilike.

So I tried the following:

$cows->where('LOWER(name)', 'like', '%' . $word . '%');

And

$cows->whereRaw('LOWER(name) like %' . $word . '%');

And

$cows->whereRaw('LOWER(name) like %?%', [$word]);

This all fails.. What am I doing wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire