public function test(Request $request){
$data=$request->all();;
$where = []; //用于外层查询条件
$whereData = []; //用于子查询条件
if(!empty($data[‘device_group_id’])){ //管制区id
$where[‘b.device_group_id’] = $whereData[‘device_group_id’] = $data[‘device_group_id’];
}
if(!empty($data[‘start_time’])){ //开始时间
$whereData[‘start_time’] = $data[‘start_time’];
}
if(!empty($data[‘end_time’])){ //结束时间
$whereData[‘end_time’] = $data[‘end_time’];
}
$data = DB::table(‘vip’. ‘ as a’)
->rightJoin(‘gate_role as b’,’a.id’,’=’,’b.vip_id’) //有门禁权限的才记录
->where($where)
->whereNotIn(‘a.id’,function ($query) use($whereData){
$query->from(‘device_group as c’)
->leftJoin(‘device_device_group as d’, ‘c.id’, ‘=’, ‘d.device_group_id’)
->leftJoin(‘device as e’, ‘d.device_id’, ‘=’, ‘e.id’)
->leftJoin(‘visitor as f’, ‘e.mac’, ‘=’, ‘f.mac’)
->where(‘c.id’, $whereData[‘device_group_id’])
->whereBetween(‘f.discern_time’,[$whereData[‘start_time’],$whereData[‘end_time’]])
->select(‘f.vip_id’);
})
->orderBy(‘a.id’, ‘desc’)
->get(array(‘a.id’,’a.name’))
->map(function($value){
return (array)$value;
})->toArray();
dd($data);
}
文章来源于互联网:laravel 子查询
very nice submit, i actually love this web site, keep on it
You really make it seem so easy along with your presentation but I find this matter to be really something which I feel I might never understand. It seems too complicated and extremely large for me. I am looking ahead to your subsequent submit, I?ll attempt to get the hang of it!
I think this is one of the most vital info for me. And i am glad reading your article. But want to remark on few general things, The web site style is ideal, the articles is really excellent : D. Good job, cheers
Primary T cell lymphoma of the breast with lymphoepithelial lesion zithromax 250 price 13 15 Endometrial hyperplasia was also found to be more common among healthy women who received preventive tamoxifen compared with untreated women
Results of Anastrozole Therapy to Date cialis professional 1995 Mar; 12 3 195- 7
do tamoxifen side effects get worse over time PMID 19567609
You re not on your back, she says amazon priligy A clinicopathologic study of 63 cases
Jsososo : http://juyifb.com/