简体   繁体   中英

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

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?

解决方法是使用FuelPHP中提供的“自定义SQL”查询功能,绕过语法限制,并获得传递给数据库的SQL查询字符串。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM