多个条件在数组里面
Array
(
[0] => 3
[1] => 13
[2] => 14
[3] => 19
[4] => 20
)
组装多条件,city_ids也可以为其它数据库字段比如:auth_id
foreach($Ids as $key=>$val){
$whereOr[] = ['', 'exp',Db::raw("FIND_IN_SET(".$val.", city_ids)") ];//标签1多选条件
}
(new ProjectModel())
->where(function($qure)use($whereOr){
$qure->whereOr($whereOr);
})->select();
执行SQL:
SELECT * FROM `tp_project` WHERE ( ( FIND_IN_SET(3, city_ids) ) OR ( FIND_IN_SET(13, city_ids) ) OR ( FIND_IN_SET(14, city_ids) ) OR ( FIND_IN_SET(19, city_ids) ) OR ( FIND_IN_SET(20, city_ids) ) )