This commit is contained in:
2022-09-09 14:31:38 +08:00

View File

@@ -12,10 +12,13 @@ class Search
return show("请输入搜索关键字"); return show("请输入搜索关键字");
} }
$lastIndex = $GLOBALS['data']['data']["lastindex"]??0; $lastIndex = $GLOBALS['data']['data']["lastindex"]??0;
$KEY = $post['keywords'];
$where = "(nickname like '{$KEY}%' or city like '{$KEY}%' or school like '{$KEY}%')";
if($lastIndex == 0){ if($lastIndex == 0){
$where = "id > 0"; $where .= " and id > 0";
}else{ }else{
$where = "id < ".$lastIndex; $where .= " and id < ".$lastIndex;
} }
$types = [1,2,3,4]; $types = [1,2,3,4];
if(!empty($GLOBALS['data']['data']["type"])){ if(!empty($GLOBALS['data']['data']["type"])){
@@ -24,14 +27,13 @@ class Search
return show("上传的类型不正确"); return show("上传的类型不正确");
} }
// if($type == 1) $where .= " and type = 1"; if($type == 1) $where .= " and type = 1";
// if($type == 2) $where .= " and type = 2"; if($type == 2) $where .= " and type = 2";
// if($type == 3) $where .= " and disabled = 1"; if($type == 3) $where .= " and disabled = 1";
} }
$KEY = $post['keywords'];
$list = Db::name("student")->where("nickname like '{$KEY}%' or city like '{$KEY}%' or school like '{$KEY}%'")->order('hot desc')->limit(env("page_count"))->where($where)->select()->toArray(); $list = Db::name("student")->where($where)->order('hot desc')->limit(env("page_count"))->where($where)->select()->toArray();
$result = StudentToArray($list); $result = StudentToArray($list);
return show(SUCCESS_MESSAGE.'!',SUCCESS_CODE,$result); return show(SUCCESS_MESSAGE.'!',SUCCESS_CODE,$result);
} }