Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在laravel查询中添加collate_Php_Mysql_Laravel_Collate - Fatal编程技术网

Php 如何在laravel查询中添加collate

Php 如何在laravel查询中添加collate,php,mysql,laravel,collate,Php,Mysql,Laravel,Collate,在我的项目中,我允许用户搜索任何东西。最近在Like查询中遇到了一个问题 Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_unicode_ci,COERCIBLE) for operation 'like' 我得到了这个问题的解决方案,但现在想在laravel查询中转换 如何编写user.name,如拉丁语“%aaa”‬%' 在laravel的->where()中校对拉丁语和瑞典语 我当前的查询代码是$qu

在我的项目中,我允许用户搜索任何东西。最近在Like查询中遇到了一个问题

Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_unicode_ci,COERCIBLE) for operation 'like'
我得到了这个问题的解决方案,但现在想在laravel查询中转换

如何编写
user.name,如拉丁语“%aaa”‬%' 在laravel的->where()中校对拉丁语和瑞典语


我当前的查询代码是
$query->where('user.name','LIKE','%'.$search'%)

您可以像这样使用
whereRaw

$query->whereRaw("user.name LIKE _latin1 '%aaa‬%' COLLATE latin1_swedish_ci");

有没有办法在where()内部使用COLLATE。@Rafikmalek您必须使用
whereRaw
而不仅仅是
where