Update DatabaseArticleManager.php

This commit is contained in:
2026-07-19 16:28:29 +02:00
parent f8aed4283e
commit b81f0c9e5c
+6 -5
View File
@@ -315,16 +315,15 @@ class DatabaseArticleManager implements ArticleManagerDAO {
FROM articles FROM articles
WHERE title LIKE :keyword WHERE title LIKE :keyword
OR content LIKE :keyword OR content LIKE :keyword
OR tags LIKE :keyword"; OR tags LIKE :keyword;";
$command = $db->prepare($sql); $command = $db->prepare($sql);
if (!$command) { if (!$command) {
throw new InternalServerErrorException("internal_error"); throw new InternalServerErrorException("internal_error");
} }
// Wildcards für die Suche hinzufügen // Wildcards für die SQL-Suche hinzufügen
$searchParam = '%' . $cleankeyword . '%'; $searchParam = '%' . $cleankeyword . '%';
$success = $command->execute([ $success = $command->execute([
":keyword" => $searchParam ":keyword" => $searchParam
]); ]);
@@ -337,10 +336,11 @@ class DatabaseArticleManager implements ArticleManagerDAO {
$filteredArticles = []; $filteredArticles = [];
foreach ($rows as $row) { foreach ($rows as $row) {
$likes = $this->getLikesForArticle(intval($row['id'])); $articleId = intval($row['id']);
$likes = $this->getLikesForArticle($articleId);
$filteredArticles[] = new Article( $filteredArticles[] = new Article(
intval($row['id']), $articleId,
$row['title'] ?? '', $row['title'] ?? '',
$row['content'] ?? '', $row['content'] ?? '',
$row['author'] ?? '', $row['author'] ?? '',
@@ -358,6 +358,7 @@ class DatabaseArticleManager implements ArticleManagerDAO {
} }
} }
/** /**
* Holt alle User-IDs, die einen bestimmten Beitrag geliked haben. * Holt alle User-IDs, die einen bestimmten Beitrag geliked haben.
* *