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 deletions
—
download
Diffstat
Diff options
+5/-4
M database.php
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 . '%']);
|