diff options
Diffstat (limited to 'inc')
-rwxr-xr-x | inc/poche/Database.class.php | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index 3b1f0af2..7ec1602d 100755 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php | |||
@@ -454,20 +454,28 @@ class Database { | |||
454 | 454 | ||
455 | public function getPreviousArticle($id, $user_id) | 455 | public function getPreviousArticle($id, $user_id) |
456 | { | 456 | { |
457 | $sql = "SELECT id FROM entries WHERE id = (SELECT max(id) FROM entries WHERE id < ? AND is_read=0) AND user_id=? AND is_read=0"; | 457 | $sqlcondition = "is_read=0"; |
458 | if (STORAGE == 'postgres') { | ||
459 | $sqlcondition = "is_read=false"; | ||
460 | } | ||
461 | $sql = "SELECT id FROM entries WHERE id = (SELECT max(id) FROM entries WHERE id < ? AND " . $sqlcondition . ") AND user_id=? AND " . $sqlcondition; | ||
458 | $params = array($id, $user_id); | 462 | $params = array($id, $user_id); |
459 | $query = $this->executeQuery($sql, $params); | 463 | $query = $this->executeQuery($sql, $params); |
460 | $id_entry = $query->fetchAll(); | 464 | $id_entry = ($query) ? $query->fetchAll() : false; |
461 | $id = ($query) ? $id_entry[0][0] : false; | 465 | $id = ($query) ? $id_entry[0][0] : false; |
462 | return $id; | 466 | return $id; |
463 | } | 467 | } |
464 | 468 | ||
465 | public function getNextArticle($id, $user_id) | 469 | public function getNextArticle($id, $user_id) |
466 | { | 470 | { |
467 | $sql = "SELECT id FROM entries WHERE id = (SELECT min(id) FROM entries WHERE id > ? AND is_read=0) AND user_id=? AND is_read=0"; | 471 | $sqlcondition = "is_read=0"; |
472 | if (STORAGE == 'postgres') { | ||
473 | $sqlcondition = "is_read=false"; | ||
474 | } | ||
475 | $sql = "SELECT id FROM entries WHERE id = (SELECT min(id) FROM entries WHERE id > ? AND " . $sqlcondition . ") AND user_id=? AND " . $sqlcondition; | ||
468 | $params = array($id, $user_id); | 476 | $params = array($id, $user_id); |
469 | $query = $this->executeQuery($sql, $params); | 477 | $query = $this->executeQuery($sql, $params); |
470 | $id_entry = $query->fetchAll(); | 478 | $id_entry = ($query) ? $query->fetchAll() : false; |
471 | $id = ($query) ? $id_entry[0][0] : false; | 479 | $id = ($query) ? $id_entry[0][0] : false; |
472 | return $id; | 480 | return $id; |
473 | } | 481 | } |