本文整理汇总了PHP中DbHandler::getAllUsers方法的典型用法代码示例。如果您正苦于以下问题:PHP DbHandler::getAllUsers方法的具体用法?PHP DbHandler::getAllUsers怎么用?PHP DbHandler::getAllUsers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbHandler
的用法示例。
在下文中一共展示了DbHandler::getAllUsers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: echoRespnse
// echo json response
echoRespnse(401, $response);
}
});
/* ---------------- METHODS WITH AUTHENTICATION ------------------ */
/**
* Listing all users excluding requested user
* method GET
* url /list_all_users.php
*/
$app->get('/list_all_users.php', 'authenticate', function () {
global $user_id;
$response = array();
$db = new DbHandler();
// fetching all users
$result = $db->getAllUsers($user_id);
if ($result) {
$response["error"] = false;
$response["users"] = array();
// looping through result and preparing user array
while ($users = $result->fetch_assoc()) {
$tmp = array();
$tmp["user_id"] = $users["user_id"];
$tmp["email"] = $users["email"];
$tmp["first_name"] = $users["first_name"];
$tmp["last_name"] = $users["last_name"];
array_push($response["users"], $tmp);
}
// echo json response
echoRespnse(200, $response);
} else {
示例2: function
$app->post('/testapikey', 'authenticate', function () {
$response = array();
$response["error"] = false;
$response["message"] = "Api key is actual";
$response["success"] = 1;
echoRespnse(200, $response);
});
/**
* Listing all users
* method GET
* url /users/all
*/
$app->get('/users/all', 'authenticate', function () {
$db = new DbHandler();
// listing all users
$result = $db->getAllUsers();
$response = array();
if ($result == null) {
$response["success"] = 0;
$response["error"] = true;
} else {
$response["success"] = 1;
$response["error"] = false;
$response["users"] = $result;
}
echoRespnse(200, $response);
});
/**
* Get user by id
* method GET
* url /users/:id