PHP搜索 搜索 搜索

//搜索界面
public function search(){
$param=input('param.');

$where=[];
//搜索框
if(!empty($param['content'])){
$where_content=['like',"%$param['content']%"];
$where=array_merge($where,['content'=>$where_content]);
}

//年龄
if(!empty($param['age'])){
//18-25
$arr=explode('-',$param['age']);
$where_age = ['age'=>[['>=',$arr[0]],['<=',$arr[1]]]];
$where=array_merge($where,['age'=>$where_age]);
}

//性别
if(!empty($param['sex'])){
$where=array_merge($where,['sex'=>$param['sex']]);
}

//地域
if(!empty($param['region'])){
$where=array_merge($where,['region'=>$param['region']]);
}

//淘气值
if(!empty($param['value'])){

$arr=explode('-',$param['value']);
if($arr[0] == 400){
$where_value=['<',$arr[0]];
}
if($arr[0] == 1000){
$where_value=['>',$arr[0]];
}
if((!empty($arr[0])) && (!empty($arr[1]))){
$where_value=[['>=',$arr[0]],['<=',$arr[1]]];
}
$where=array_merge($where,['value'=>$where_value]);
}

//做过次数
if(!empty($param['times'])){
$arr=explode('-',$param['times']);
if($arr[0]==3){
$where_times=['<',$arr[0]];
}
if($arr[0]==15){
$where_times=['>',$arr[0]];
}
if((!empty($arr[0])) && (!empty($arr[1]))){
$where_times=[['>=',$arr[0]],['<=',$arr[1]]];
}
$where=array_merge($where,['times'=>$where_times]);
}

//是否黑号
if(!empty($param['is_black'])){
$where=array_merge($where,['is_black'=>$param['is_black']]);
}

//买家能力有无
if(!empty($param['is_availity'])){
$where=array_merge($where,['is_availity'=>$param['is_availity']]);
}
$data=db('search')->where($where)->select();
}

posted on 2018-07-06 17:32  旺仔小裤头  阅读(278)  评论(0编辑  收藏  举报