diff options
-rwxr-xr-x | inc/poche/Database.class.php | 22 | ||||
-rwxr-xr-x | install/index.php | 12 |
2 files changed, 23 insertions, 11 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index 28d4a232..7ec1602d 100755 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php | |||
@@ -266,10 +266,10 @@ class Database { | |||
266 | { | 266 | { |
267 | $entries = $this->retrieveAll($userID); | 267 | $entries = $this->retrieveAll($userID); |
268 | if ($entries) { | 268 | if ($entries) { |
269 | foreach($entries as $entryid) { | 269 | foreach($entries as $entry) { |
270 | $tags = $this->retrieveTagsByEntry($entryid); | 270 | $tags = $this->retrieveTagsByEntry($entry['id']); |
271 | foreach($tags as $tag) { | 271 | foreach($tags as $tag) { |
272 | $this->removeTagForEntry($entryid,$tags); | 272 | $this->removeTagForEntry($entry['id'], $tags); |
273 | } | 273 | } |
274 | $this->deleteById($entryid,$userID); | 274 | $this->deleteById($entryid,$userID); |
275 | } | 275 | } |
@@ -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 | } |
diff --git a/install/index.php b/install/index.php index bb351095..ea5d7d47 100755 --- a/install/index.php +++ b/install/index.php | |||
@@ -94,10 +94,14 @@ else if (isset($_POST['install'])) { | |||
94 | $errors[] = 'Impossible to create the SQLite database file. Please check your file permissions.'; | 94 | $errors[] = 'Impossible to create the SQLite database file. Please check your file permissions.'; |
95 | } | 95 | } |
96 | else { | 96 | else { |
97 | $db_path = 'sqlite:' . realpath('') . '/db/poche.sqlite'; | 97 | try { |
98 | $handle = new PDO($db_path); | 98 | $db_path = 'sqlite:' . realpath('') . '/db/poche.sqlite'; |
99 | $handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | 99 | $handle = new PDO($db_path); |
100 | $sql_structure = ""; | 100 | $handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
101 | $sql_structure = ""; | ||
102 | } catch (PDOException $e) { | ||
103 | $errors[] = "SQLite has encountered an issue : " . $e->getMessage(); | ||
104 | } | ||
101 | } | 105 | } |
102 | } else { | 106 | } else { |
103 | // MySQL and Postgre | 107 | // MySQL and Postgre |