Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.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
Laravel 5 在where方法中使用原始查询会导致查询生成错误_Laravel 5 - Fatal编程技术网

Laravel 5 在where方法中使用原始查询会导致查询生成错误

Laravel 5 在where方法中使用原始查询会导致查询生成错误,laravel-5,Laravel 5,我有一个很有说服力的问题 Role::where("(company_id = Auth::user()->company_id or name = 'admin')and id in(2,3)")->pluck('name'); 根据我的口才,sql应该是 select `name` from `roles` where ( company_id = 1 or name = admin ) and id IN (2, 3) and `roles`.`deleted_at` is

我有一个很有说服力的问题

Role::where("(company_id = Auth::user()->company_id or name = 'admin')and id in(2,3)")->pluck('name');
根据我的口才,sql应该是

select `name` from `roles` where ( company_id = 1 or name = admin ) and id IN (2, 3) and `roles`.`deleted_at` is null
但它的执行方式是

select `name` from `roles` where ( company_id = 1 or name = admin ) and id IN (2, 3) is null and `roles`.`deleted_at` is null
有人能帮我总结一下为什么在查询中应用了extra
为null
条件吗


注意:我使用的是软删除

您应该使用whereRaw而不是where

Role::whereRaw("(company_id = Auth::user()->company_id or name = 'admin')and id in(2,3)")->pluck('name');

请格式化你的问题。非常令人困惑的是,您的实际PHP代码是什么?