1) { $stmt->bind_param(str_repeat("s", count($param)), $param[0], ...array_slice($param, 1)); } else if (count($param) == 1) { $stmt->bind_param(str_repeat("s", count($param)), $param[0]); } } }; DbUtil::query($sql, $garbage_result, $keyword); return $garbage_result; } } if (empty($_GET)) { json_res(json_encode(array("status" => false, "error" => "非法请求"), JSON_UNESCAPED_UNICODE)); } else if (isset($_GET["keyword"]) and !empty($_GET["keyword"])) { $result = QueryGarbageWithName("select * from garbage where name like ?", array("%" . $_GET["keyword"] . "%")); json_res(json_encode(array("status" => true, "result" => $result->getGarbageObjArray(), "keyword" => $_GET["keyword"]), JSON_UNESCAPED_UNICODE)); } else if (isset($_GET["category"]) and is_numeric($_GET["category"])) { $result = QueryGarbageWithName("select * from garbage where category = ?", array((int)$_GET["category"])); json_res(json_encode(array("status" => true, "result" => $result->getGarbageObjArray(), "category" => $_GET["category"]), JSON_UNESCAPED_UNICODE)); } else { json_res(json_encode(array("status" => false, "error" => "非法查询参数"), JSON_UNESCAPED_UNICODE)); }