Начал делать API для постов
This commit is contained in:
@@ -5,6 +5,21 @@ require_once("../_utils.php");
|
||||
|
||||
|
||||
|
||||
// Increment number of views for post
|
||||
function Post_AddView ($id) {
|
||||
global $db;
|
||||
|
||||
$s = $db->prepare("UPDATE posts SET views = views + 1 WHERE id = ?");
|
||||
$s->bind_param("s", $id);
|
||||
$s->execute();
|
||||
$d = $s->get_result()->fetch_assoc();
|
||||
|
||||
if (!(bool)$d) {
|
||||
require_once("../_json.php");
|
||||
ReturnJSONError($Err_Int_Unexpected, "failed to increment number of views");
|
||||
}
|
||||
}
|
||||
|
||||
// Get single publication by ID
|
||||
function Post_GetByID ($id) {
|
||||
global $db;
|
||||
@@ -34,7 +49,7 @@ function Post_GetByID ($id) {
|
||||
$result["preview_path"] = $d["preview_path"];
|
||||
$result["edit_lock"] = $d["edit_lock"];
|
||||
|
||||
// TODO: increment views of post
|
||||
Post_AddView($id);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user