/**
* 关键字多条件搜索 - 以姓名或者电话搜索
*/
public function search_key(){
$salesman_id = input('post.salesman_id');
$key = input('post.keyword');
$where['salesman_id'] = $salesman_id;
$where1 = [];
if($key){
$where['salesman_id'] = $salesman_id;
$where['username'] = array('LIKE','%'.$key.'%');
$where1['salesman_id'] = $salesman_id;
$where1['phone'] = array('LIKE','%'.$key.'%');
}
$list = db('customer')
->where(function ($query) use ($where) {
$query->where($where);
})->whereOr(function ($query) use ($where1) {
$query->where($where1);
})->select();
if(count($list) == 0){
return json(['status' => 0,'msg' => '到底啦']);
}
return json(['status' => 1,'msg' => '成功','data' => $list]);
}
thinkphp5实现关键字多条件搜索功能
最新推荐文章于 2024-02-26 16:56:23 发布