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.
103 lines
2.2 KiB
103 lines
2.2 KiB
<?php
|
|
|
|
require_once __ROOT__ . "/entity/ApiToken.php";
|
|
require_once __ROOT__ . "/entity/Garbage.php";
|
|
|
|
//Token查询
|
|
abstract class AbstractTokenQuery implements DoExcute
|
|
{
|
|
// token查询结果
|
|
private $token_array = array();
|
|
|
|
/**
|
|
* TokenQuery constructor.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
}
|
|
|
|
|
|
// 绑定toekn信息
|
|
public function doResult(mysqli_stmt $stmt)
|
|
{
|
|
/**
|
|
*
|
|
* $col1 $id
|
|
* $col2 $refresh_token
|
|
* $col3 $expires_in
|
|
* $col4 $end_time
|
|
* $col5 $scope
|
|
* $col6 $session_key
|
|
* $col7 $access_token
|
|
* $col8 $session_secret
|
|
*/
|
|
$stmt->bind_result($col1, $col2, $col3, $col4, $col5, $col6, $col7, $col8);
|
|
while ($stmt->fetch()) {
|
|
array_push($this->token_array, new ApiToken($col1, $col2, $col3, $col4, $col5, $col6, $col7, $col8));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getTokenArray(): array
|
|
{
|
|
return $this->token_array;
|
|
}
|
|
|
|
function getToken(): ApiToken
|
|
{
|
|
return $this->token_array[0];
|
|
}
|
|
|
|
|
|
}
|
|
|
|
//垃圾分类查询
|
|
abstract class AbstractGarbageQuery implements DoExcute
|
|
{
|
|
// 垃圾分类查询结果
|
|
private $garbage_obj_array = array();
|
|
|
|
|
|
public function doResult(mysqli_stmt $stmt)
|
|
{
|
|
|
|
$stmt->bind_result($col1, $col2, $col3, $col4);
|
|
while ($stmt->fetch()) {
|
|
$g = new Garbage($col1, $col2, $col3, $col4);
|
|
array_push($this->garbage_obj_array, $g);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getGarbageObjArray(): array
|
|
{
|
|
return $this->garbage_obj_array;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
function getGarbageQuery($sql, $keyword): AbstractGarbageQuery
|
|
{
|
|
$garbage_result = new class() extends AbstractGarbageQuery
|
|
{
|
|
public function bind_param(mysqli_stmt $stmt, array $param)
|
|
{
|
|
if (count($param) > 1) {
|
|
$stmt->bind_param(str_repeat("s", count($param)), $param[0], ...array_slice($param, 1));
|
|
} else {
|
|
$stmt->bind_param(str_repeat("s", count($param)), $param[0]);
|
|
}
|
|
|
|
}
|
|
};
|
|
|
|
DbUtil::query($sql, $garbage_result, $keyword);
|
|
|
|
return $garbage_result;
|
|
} |