From b81f0c9e5c8c7d2aa5dcff562f25ad97096d5ea4 Mon Sep 17 00:00:00 2001 From: NOrtmann1 Date: Sun, 19 Jul 2026 16:28:29 +0200 Subject: [PATCH] Update DatabaseArticleManager.php --- php/model/DatabaseArticleManager.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/php/model/DatabaseArticleManager.php b/php/model/DatabaseArticleManager.php index 207207e..c9485b5 100644 --- a/php/model/DatabaseArticleManager.php +++ b/php/model/DatabaseArticleManager.php @@ -310,21 +310,20 @@ class DatabaseArticleManager implements ArticleManagerDAO { try { $db = $this->getConnection(); - + $sql = "SELECT id, title, content, author, category, tags, created - FROM articles - WHERE title LIKE :keyword - OR content LIKE :keyword - OR tags LIKE :keyword"; + FROM articles + WHERE title LIKE :keyword + OR content LIKE :keyword + OR tags LIKE :keyword;"; $command = $db->prepare($sql); if (!$command) { throw new InternalServerErrorException("internal_error"); } - // Wildcards für die Suche hinzufügen + // Wildcards für die SQL-Suche hinzufügen $searchParam = '%' . $cleankeyword . '%'; - $success = $command->execute([ ":keyword" => $searchParam ]); @@ -337,10 +336,11 @@ class DatabaseArticleManager implements ArticleManagerDAO { $filteredArticles = []; foreach ($rows as $row) { - $likes = $this->getLikesForArticle(intval($row['id'])); + $articleId = intval($row['id']); + $likes = $this->getLikesForArticle($articleId); $filteredArticles[] = new Article( - intval($row['id']), + $articleId, $row['title'] ?? '', $row['content'] ?? '', $row['author'] ?? '', @@ -358,6 +358,7 @@ class DatabaseArticleManager implements ArticleManagerDAO { } } + /** * Holt alle User-IDs, die einen bestimmten Beitrag geliked haben. *