[英]How to add collate in laravel query
In my project I am allowing user to search any thing.在我的项目中,我允许用户搜索任何东西。 Recently facing an issue in Like query.
最近在 Like 查询中遇到了一个问题。
Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_unicode_ci,COERCIBLE) for operation 'like'
I got a solution for this issue but now want to convert in laravel query.我得到了解决这个问题的方法,但现在想在 laravel 查询中进行转换。
How I can write user.name LIKE _latin1 '%aaa%' COLLATE latin1_swedish_ci
this in ->where() of laravel我如何在 laravel 的 ->where() 中编写
user.name LIKE _latin1 '%aaa%' COLLATE latin1_swedish_ci
latin1_swedish_ci
and my current query code is $query->where('user.name', 'LIKE', '%'.$search.'%');
我当前的查询代码是
$query->where('user.name', 'LIKE', '%'.$search.'%');
You can use whereRaw
like this你可以像这样使用
whereRaw
$query->whereRaw("user.name LIKE _latin1 '%aaa%' COLLATE latin1_swedish_ci");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.