Case insensitive `like` with FuelPHP's orm and mysql

310 Views Asked by At

I am using FuelPHP and MySQL, and would like to use the ORM to query with a case insensitive like query against a column with a case sensitive collation.

For example, in my orm model, I'd like to do something like this:

public static function search_by_name($name)
{
    return self::query()->where('name', 'like', '%' . $name . '%')->get();
}

The problem here is that when I search for $name = 'john', the expression will not match rows where the column includes John and vice-versa.

Anyone know how to get around this?

1

There are 1 best solutions below

0
spencer7593 On

The workaround is to use the "Custom SQL" query feature available in FuelPHP, to bypass the syntax limitations, and get a SQL query string passed to the database.