You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
wastesortingserver/api/QueryText.php

30 lines
1.7 KiB

<?php
require_once $_SERVER["DOCUMENT_ROOT"] . "/config.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/api/JsonResponse.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/database/DbUtil.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/database/Query.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/Log.php";
if (empty($_GET)) {
json_res(json_encode(array("status" => false, "error" => "非法请求"), JSON_UNESCAPED_UNICODE));
} else if (isset($_GET["keyword"]) and !empty($_GET["keyword"])) {
$query_result = new QueryGarbage();
try {
DbUtil::query("select * from garbage where name like ?", $query_result, array("%" . $_GET["keyword"] . "%"));
json_res(json_encode(array("status" => true, "result" => $query_result->getGarbageObjArray(), "keyword" => $_GET["keyword"]), JSON_UNESCAPED_UNICODE));
} catch (Exception $e) {
json_res(json_encode(array("status" => false, "error" => "系统出现严重异常,请联系管理员"), JSON_UNESCAPED_UNICODE));
}
} else if (isset($_GET["category"]) and is_numeric($_GET["category"])) {
$query_result = new QueryGarbage();
try {
DbUtil::query("select * from garbage where category = ?", $query_result, array((int)$_GET["category"]));
json_res(json_encode(array("status" => true, "result" => $query_result->getGarbageObjArray(), "category" => $_GET["category"]), JSON_UNESCAPED_UNICODE));
} catch (Exception $e) {
json_res(json_encode(array("status" => false, "error" => "系统出现严重异常,请联系管理员"), JSON_UNESCAPED_UNICODE));
}
} else {
json_res(json_encode(array("status" => false, "error" => "非法查询参数"), JSON_UNESCAPED_UNICODE));
}