数据库里有2条数据,返回的是{"code":400,"message":"error","data":[]},不知道问题出在哪了?
<?php
require_once ('./Helper/response.php');
require_once ('./Helper/db.php');
$sql = "select * from userAccount";
try{
$connect = Db::getInstance()->connect();
}catch (Exception $e){
return Response::show(403,'数据库连接失败');
}
$result = mysqli_query($sql,$connect);
$users = array();
while ($user = mysqli_fetch_assoc($result)){
$users[] = $user;
}
if ($users){
return Response::show(200,'success');
}
else{
return Response::show(400,'error');
}