Delete return pages
This commit is contained in:
@@ -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];
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user