在thinkphp5中如何实现or查询
可以通过以下代码来实现
> $map['user_id']=1;
$map['status']=0;
$or_map['user_id']=$map['user_id'];
$or_map['audit']=['in',['1,2']];
$list = Db::name('tablename')->where(function ($query) use ($map) {
$query->where($map);
})->whereOr(function ($query) use ($or_map) {
$query->where($or_map);
})->limit(0,$pn*$page_size)->select();
可以生成以下sql
> SELECT * FROM `tablename` WHERE ( `user_id` = '1' AND `status` = 0 ) OR ( `user_id` = '1' AND `audit` IN ('1,2') )