Skip to content

Commit

Permalink
fix order by desc ordering of items
Browse files Browse the repository at this point in the history
  • Loading branch information
niol authored and jtojnar committed Feb 12, 2017
1 parent bf2388f commit a0f293b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions daos/mysql/Items.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public function get($options = array()) {
items.id, datetime, items.title AS title, content, unread, starred, source, thumbnail, icon, uid, link, updatetime, author, sources.title as sourcetitle, sources.tags as tags
FROM '.\F3::get('db_prefix').'items AS items, '.\F3::get('db_prefix').'sources AS sources
WHERE items.source=sources.id AND';
$order = 'ORDER BY items.datetime,items.id '.$order;
$order_sql = 'ORDER BY items.datetime ' . $order . ', items.id ' . $order;

if( $where_ids != '' ) {
// This UNION is required for the extra explicitely requested items
Expand All @@ -315,13 +315,13 @@ public function get($options = array()) {
// complaining about 'order by clause should come after union not
// before'.
$query = "SELECT * FROM (
SELECT * FROM ($select $where_sql $order LIMIT " . $options['items'] . ' OFFSET '. $options['offset'] . ") AS entries
SELECT * FROM ($select $where_sql $order_sql LIMIT " . $options['items'] . ' OFFSET '. $options['offset'] . ") AS entries
UNION
$select $where_ids
) AS items
$order";
$order_sql";
} else {
$query = "$select $where_sql $order LIMIT " . $options['items'] . ' OFFSET '. $options['offset'];
$query = "$select $where_sql $order_sql LIMIT " . $options['items'] . ' OFFSET '. $options['offset'];
}

return \F3::get('db')->exec($query, $params);
Expand Down

0 comments on commit a0f293b

Please sign in to comment.