Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.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参数分组(和/或其中)_Laravel - Fatal编程技术网

Laravel参数分组(和/或其中)

Laravel参数分组(和/或其中),laravel,Laravel,我将Laravel升级到了第7版,当我进行这样的查询时: $users = User::where('name', '=', 'John') ->where(function ($query) { $query->where('votes', '>', 100) ->orWhereNull('title'); }) ->get()

我将Laravel升级到了第7版,当我进行这样的查询时:

$users = User::where('name', '=', 'John')
           ->where(function ($query) {
               $query->where('votes', '>', 100)
                     ->orWhereNull('title');
           })
           ->get();
它无法按预期工作,我遇到了此错误
[SQL Server]必须指定要从中选择的表

因为SQL应该是这样的:

select * from users where name = 'John' and (votes > 100 or title is null)
select * from users where name = 'John' and (select * votes > 100 or title is null) is null
但当我调试返回的查询时,它显示如下:

select * from users where name = 'John' and (votes > 100 or title is null)
select * from users where name = 'John' and (select * votes > 100 or title is null) is null

上面的查询只是我复杂查询的一个例子,我的所有项目中都有很多类似的查询,因此我不需要替换,我只需要知道如何修复它,因为它在升级之前工作正常。例如,您可以使用
whereRaw
作为替代方法

$users = Table::whereRaw(" name=? AND (votes=? OR title=?)", array(?,?,?))