home » zplus/freepost.git
Author zPlus <--> 2016-11-29 00:47:13
Committer zPlus <--> 2016-11-29 00:47:13
Commit ba242a1 (patch)
Tree e27df25
Parent(s)

database.php: update search function - join results with username - change results order from ASC to DESC


commits diff: 6aace0c..ba242a1
1 file changed, 5 insertions, 4 deletionsdownload


Diffstat
-rw-r--r-- database.php 9

Diff options
View
Side
Whitespace
Context lines
Inter-hunk lines
+5/-4 M   database.php
index 1c762cb..27fb167
old size: 41K - new size: 41K
@@ -1332,10 +1332,11 @@ class Database
1332 1332 $search_query = str_ireplace (' ', '%', $search_query);
1333 1333
1334 1334 $query = $this->database->prepare (
1335 - 'SELECT * ' .
1336 - 'FROM `post`' .
1337 - 'WHERE `title` LIKE ? ' .
1338 - 'ORDER BY `created`' .
1335 + 'SELECT P.*, U.`username` ' .
1336 + 'FROM `post` AS P ' .
1337 + 'JOIN `user` AS U ON P.`userId` = U.`id`' .
1338 + 'WHERE P.`title` LIKE ? ' .
1339 + 'ORDER BY P.`created` DESC ' .
1339 1340 'LIMIT 100');
1340 1341
1341 1342 $query->execute (['%' . $search_query . '%']);