From 5125612c05caf37ee975299a8ed059f6af758bee Mon Sep 17 00:00:00 2001 From: Josh Ashton Date: Sun, 30 Mar 2025 21:08:05 -0600 Subject: [PATCH] implemented order by on filter by tag. --- functions/article_functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/article_functions.php b/functions/article_functions.php index 44c2d09..b7256a5 100644 --- a/functions/article_functions.php +++ b/functions/article_functions.php @@ -16,7 +16,7 @@ function article_ids_by_recency() function articles_ids_by_author($author_id) { - $query = 'SELECT article_id FROM article ORDER BY published_at DESC WHERE author_id = ' . $author_id . ';'; + $query = 'SELECT article_id FROM article WHERE author_id = ' . $author_id . ' ORDER BY published_at DESC;'; $results = query_one_or_more_results($query); $ids = []; @@ -41,7 +41,7 @@ function article_tags() function article_ids_by_tag($tag_id) { - $query = 'SELECT article_id FROM article_tags INNER JOIN tags ON article_tags.tag_id = tags.tag_id WHERE tag = "' . $tag_id . '";'; + $query = 'SELECT article_id FROM article WHERE article.article_id IN ( SELECT article_tags.article_id FROM article_tags INNER JOIN tags ON article_tags.tag_id = tags.tag_id WHERE tag = "' . $tag_id . '") ORDER BY published_at DESC;'; $results = query_one_or_more_results($query); $ids = [];