Database - und LocalArticleManager angepasst, sodass nun auch nach tags gesucht wird. #47
@@ -338,7 +338,8 @@ class DatabaseArticleManager implements ArticleManagerDAO {
|
|||||||
$sql = "SELECT id, title, content, author, category, tags, created
|
$sql = "SELECT id, title, content, author, category, tags, created
|
||||||
FROM articles
|
FROM articles
|
||||||
WHERE title LIKE :keyword
|
WHERE title LIKE :keyword
|
||||||
OR content LIKE :keyword;";
|
OR content LIKE :keyword
|
||||||
|
OR tags LIKE :keyword";
|
||||||
|
|
||||||
$command = $db->prepare($sql);
|
$command = $db->prepare($sql);
|
||||||
if (!$command) {
|
if (!$command) {
|
||||||
|
|||||||
@@ -211,9 +211,11 @@ class LocalArticleManager implements ArticleManagerDAO {
|
|||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
$title = isset($article['title']) ? strtolower((string)$article['title']) : '';
|
$title = isset($article['title']) ? strtolower((string)$article['title']) : '';
|
||||||
$content = isset($article['content']) ? strtolower((string)$article['content']) : '';
|
$content = isset($article['content']) ? strtolower((string)$article['content']) : '';
|
||||||
|
$tags = isset($article['tags']) ? strtolower((string)$article['tags']) : '';
|
||||||
|
|
||||||
if (($cleanKeyword !== '' && strpos($title, $cleanKeyword) !== false) ||
|
if (($cleanKeyword !== '' && strpos($title, $cleanKeyword) !== false) ||
|
||||||
($cleanKeyword !== '' && strpos($content, $cleanKeyword) !== false)) {
|
($cleanKeyword !== '' && strpos($content, $cleanKeyword) !== false) ||
|
||||||
|
($cleanKeyword !== '' && strpos($tags, $cleanKeyword) !== false)) {
|
||||||
|
|
||||||
$likes = isset($article['likes']) && is_array($article['likes']) ? $article['likes'] : [];
|
$likes = isset($article['likes']) && is_array($article['likes']) ? $article['likes'] : [];
|
||||||
$filteredArticles[] = new Article(
|
$filteredArticles[] = new Article(
|
||||||
|
|||||||
Reference in New Issue
Block a user