本文整理匯總了PHP中DbHandler::getPostById方法的典型用法代碼示例。如果您正苦於以下問題:PHP DbHandler::getPostById方法的具體用法?PHP DbHandler::getPostById怎麽用?PHP DbHandler::getPostById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DbHandler
的用法示例。
在下文中一共展示了DbHandler::getPostById方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: while
array_push($response["posts"], $tmp3);
}
} while ($post = $result->fetch_assoc());
$response["message"] = "Query Successful";
} else {
$response["error"] = true;
$response["message"] = "One or more field(s) missing or invalid.";
}
echoResponse(200, $response);
});
$app->get('/getpostbyid', function () use($app) {
$response = array();
$postId = $app->request()->get('postId');
$db = new DbHandler();
// fetching all user tasks
$result = $db->getPostById($postId);
if ($result) {
$response["error"] = false;
$response["posts"] = array();
$response["comments"] = array();
// looping through result and preparing updates array
// while ($update = $result->fetch_assoc()) {
$post = $result->fetch_assoc();
$tmp = array();
$tmp["id"] = $post["id"];
$tmp["locationId"] = $post["locationId"];
$tmp["posterId"] = $post["posterId"];
$tmp["posterName"] = $post["username"];
$tmp["postType"] = $post["type"];
$tmp["description"] = $post["description"];
$tmp["likeCount"] = $post["likeCount"];