Browse Source

SQL: Bug with order ASC

https://github.com/marienfressinaud/FreshRSS/issues/538
Alexandre Alapetite 11 years ago
parent
commit
3403af3050
1 changed files with 1 additions and 1 deletions
  1. 1 1
      app/Models/EntryDAO.php

+ 1 - 1
app/Models/EntryDAO.php

@@ -353,7 +353,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
 				throw new FreshRSS_EntriesGetter_Exception('Bad order in Entry->listByType: [' . $order . ']!');
 				throw new FreshRSS_EntriesGetter_Exception('Bad order in Entry->listByType: [' . $order . ']!');
 		}
 		}
 		if ($firstId === '' && parent::$sharedDbType === 'mysql') {
 		if ($firstId === '' && parent::$sharedDbType === 'mysql') {
-			$firstId = '9000000000' . '000000';	//MySQL optimization. Tested on MySQL 5.5 with 150k articles
+			$firstId = $order === 'DESC' ? '9000000000'. '000000' : '0';	//MySQL optimization. Tested on MySQL 5.5 with 150k articles
 		}
 		}
 		if ($firstId !== '') {
 		if ($firstId !== '') {
 			$where .= 'AND e1.id ' . ($order === 'DESC' ? '<=' : '>=') . $firstId . ' ';
 			$where .= 'AND e1.id ' . ($order === 'DESC' ? '<=' : '>=') . $firstId . ' ';