本文整理匯總了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