From ba242a111736da852ec83811876aff4541c51c33 Mon Sep 17 00:00:00 2001 From: zPlus <--> Date: Tue, 29 Nov 2016 01:47:13 +0100 Subject: [PATCH] database.php: update search function - join results with username - change results order from ASC to DESC --- database.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/database.php b/database.php index 1c762cba..27fb1670 100644 --- a/database.php +++ b/database.php @@ -1332,10 +1332,11 @@ class Database $search_query = str_ireplace (' ', '%', $search_query); $query = $this->database->prepare ( - 'SELECT * ' . - 'FROM `post`' . - 'WHERE `title` LIKE ? ' . - 'ORDER BY `created`' . + 'SELECT P.*, U.`username` ' . + 'FROM `post` AS P ' . + 'JOIN `user` AS U ON P.`userId` = U.`id`' . + 'WHERE P.`title` LIKE ? ' . + 'ORDER BY P.`created` DESC ' . 'LIMIT 100'); $query->execute (['%' . $search_query . '%']);