这是我的模型功能,现在它正常工作,但我想检查哪里(或)或其他地方。我已经尝试过,但无法得到合适的答案
public static function getPlacementCountByStatus(){
$countStatus = DB::table('placements')->where('status','1')->select(DB::raw('count(joborderid) as total, joborderid'))->groupBy('joborderid')->get();
return $countStatus;
}
我想查看类似的内容
->where('statusid','=','3')->orWhere('statusid','=','4')->orWhere('stageid','=','4')->orWhere('stageid','=','8');
//我想在我的$ countStatus中检查一下这个和我的db :: raw查询中的条件
答案 0 :(得分:2)
使用where()关闭:
<video width="400" controls>
<source src={this.state.data} type="video/mp4" />
Your browser does not support HTML5 video.
</video>
$countStatus = DB::table('placements')->where(function($q){ $q->where('statusid','=','3')->orWhere('statusid','=','4')->orWhere('stageid','=','4')->orWhere('stageid','=','8'); }) ->select(DB::raw('count(placementid) as total,statusid')) ->groupBy('statusid')->get(); return $countStatus;
有时您可能需要创建更高级的where子句,例如From the docs
子句或嵌套参数分组。
在您的情况下,您需要在尝试"where exists"
操作时使用where closure
,这意味着您正在尝试combine AND,OR
块中的group your parameters
。这里closure
主要执行parenthesis
在SQL查询中的作用。