Update DatabaseArticleManager.php

This commit is contained in:
2026-07-19 16:28:29 +02:00
parent f8aed4283e
commit b81f0c9e5c
+10 -9
View File
@@ -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.
*