Php 我怎样才能在拉雷维尔雄辩地做一个where和where?

Php 我怎样才能在拉雷维尔雄辩地做一个where和where?,php,laravel,eloquent,fluent,Php,Laravel,Eloquent,Fluent,这就是我目前拥有的: $query->orderBy('id', 'DESC') ->where('totalColorless', '!=', 0) // currently removes all of these... ->where('totalResidual', '!=', 0) // ...and all of these ->get(); 如何使其同时删除满足两个WHERE条件的行 尝试使用“orWhe

这就是我目前拥有的:

$query->orderBy('id', 'DESC')

        ->where('totalColorless', '!=', 0) // currently removes all of these...
        ->where('totalResidual', '!=', 0) // ...and all of these

        ->get();
如何使其同时删除满足两个WHERE条件的行

尝试使用“orWhere”:


我想你必须把
orderBy()
放在
get()
之前和
where()

之后,否则我误解了你的问题,或者你的查询已经在做你要问的事情了。这是在做
WHERE private!=1和总无色!=0和Total残差!=0
有些列的total无色=0,但total残差=1,反之亦然。基本上我想同时删除total无色=0和total残数=0的行。。为什么你的查询不能是这样的呢?
->where('total无色','=',0)->where('total残余数','=',0)
只要
->where('total无色',0)->where('total残余数',0)
就可以了。我试过了,但奇怪的是,它工作正常。如果您更改为orWhere,我将选择您的作为答案。已更改,但您确实需要执行
或where
?奇怪的是,orWhere在php中的作用与AND相同。也许MySQL命令的命名很奇怪?我认为您可以使用
->getQueryLog()
->toSql()
获取查询字符串并进行检查
[...]
->where('totalColorless', '!=', 0)
->orWhere('totalResidual', '!=', 0)
[...]