Fehlerbehebung

This commit is contained in:
2026-06-15 23:41:28 +02:00
parent e20b59b43d
commit c4c299eed6
4 changed files with 66 additions and 30 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ interface CommentManagerDAO
* @param string $content Inhalt des Kommentars
* @param int|null $parentCommentId ID des Eltern-Kommentars oder null
*
* @return void
* @return int ID des neu gespeicherten Kommentars
*/
public function addComment(
$articleId,
+19 -17
View File
@@ -102,7 +102,7 @@ class DatabaseCommentManager implements CommentManagerDAO
* @param string $content Inhalt des Kommentars
* @param int|null $parentCommentId ID des Eltern-Kommentars oder null
*
* @return void
* @return int ID des neu gespeicherten Kommentars
*/
public function addComment(
$articleId,
@@ -141,6 +141,8 @@ class DatabaseCommentManager implements CommentManagerDAO
":content" => $content
]);
return intval($db->lastInsertId());
} catch (PDOException $e) {
throw new RuntimeException(
"Kommentar konnte nicht gespeichert werden."
@@ -162,22 +164,22 @@ class DatabaseCommentManager implements CommentManagerDAO
$db = $this->getConnection();
$sql = "
SELECT
id,
article_id,
CASE
WHEN parent_comment_id IS NULL THEN NULL
WHEN parent_comment_id = '' THEN NULL
WHEN parent_comment_id = 0 THEN NULL
ELSE parent_comment_id
END AS parent_comment_id,
author,
content,
created
FROM comments
WHERE article_id = :articleId
ORDER BY created ASC
";
SELECT
id,
article_id,
CASE
WHEN parent_comment_id IS NULL THEN NULL
WHEN parent_comment_id = '' THEN NULL
WHEN parent_comment_id = 0 THEN NULL
ELSE parent_comment_id
END AS parent_comment_id,
author,
content,
created
FROM comments
WHERE article_id = :articleId
ORDER BY created ASC
";
$command = $db->prepare($sql);