Delete return pages

This commit is contained in:
2024-07-27 17:01:24 +02:00
parent ce7ba50b9d
commit 6018e8bee5
4 changed files with 20 additions and 7 deletions
+11 -2
View File
@@ -165,14 +165,23 @@ class Post implements JsonSerializable
return Post::getByID($this->id);
}
public function delete(): Post
public function delete(int $limit): array
{
$db = Database::getInstance();
$stmt = $db->prepare("DELETE FROM egb_gaestebuch WHERE id = :ID");
$stmt->bindValue(":ID", $this->id);
$stmt->execute();
return $this;
$stmt = $db->prepare(
"SELECT
COUNT(*)
FROM
egb_gaestebuch"
);
$stmt->execute();
$count = $stmt->fetch(PDO::FETCH_COLUMN, 0);
return ["pages" => intdiv($count, $limit + 1) + 1, "data" => $this];
}
/*