Post Create/Edit
This commit is contained in:
@@ -58,7 +58,7 @@ class Post implements JsonSerializable
|
||||
return new Post($data["id"], $user, null, null, $data["beitrag"], $data["zeitstempel"]);
|
||||
}
|
||||
|
||||
public static function create(User $user, string $content): Post
|
||||
public static function create(User $user, string $content, int $limit): array
|
||||
{
|
||||
$content = substr(trim($content), 0, 250);
|
||||
|
||||
@@ -73,8 +73,21 @@ class Post implements JsonSerializable
|
||||
$stmt->bindValue(":CON", nl2br(htmlspecialchars($content)));
|
||||
|
||||
$stmt->execute();
|
||||
$lastId = $db->lastInsertId();
|
||||
|
||||
return Post::getByID($db->lastInsertId());
|
||||
$stmt = $db->prepare(
|
||||
"SELECT
|
||||
COUNT(*)
|
||||
FROM
|
||||
egb_gaestebuch"
|
||||
);
|
||||
$stmt->execute();
|
||||
$count = $stmt->fetch(PDO::FETCH_COLUMN, 0);
|
||||
|
||||
return [
|
||||
"pages" => intdiv($count, $limit + 1) + 1,
|
||||
"post" => Post::getByID($lastId)
|
||||
];
|
||||
}
|
||||
|
||||
public static function list(int $page, int $limit, bool $authed = false): array
|
||||
|
||||
Reference in New Issue
Block a user