前言
最近在开发项目的时候遇到过一个查询条件:需要对一个字段进行多个模糊查询。
解决办法
public function getGroupUser($title)
{
//多个where条件查询
$condition = ['建设单位','监理单位','数字化单位'];
$where_supervisor['title'] = array('or');
foreach ($condition as $value) {
array_unshift($where_supervisor['title'], array('like', '%' . $value . '%'));
}
//拼接搜索条件
$query = self::where($where_supervisor);
return $query->order('key desc')->select();
}