aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche/Database.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/poche/Database.class.php')
-rwxr-xr-xinc/poche/Database.class.php22
1 files changed, 15 insertions, 7 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 }