aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche/Database.class.php
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2015-03-13 16:49:20 +0100
committerThomas Citharel <tcit@tcit.fr>2015-03-13 16:49:20 +0100
commitf76dab12c9913e0bf4bafd8f59cccdb6bf395994 (patch)
treeeed9ddd964b650b3f8696359b082c2a8cc5242c8 /inc/poche/Database.class.php
parentab87a7fe6934b5fa0f06964c67a27826774126b4 (diff)
downloadwallabag-f76dab12c9913e0bf4bafd8f59cccdb6bf395994.tar.gz
wallabag-f76dab12c9913e0bf4bafd8f59cccdb6bf395994.tar.zst
wallabag-f76dab12c9913e0bf4bafd8f59cccdb6bf395994.zip
fix for #1153, a couple of improvements and fixed bugs
Diffstat (limited to 'inc/poche/Database.class.php')
-rwxr-xr-xinc/poche/Database.class.php18
1 files changed, 15 insertions, 3 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php
index 4f55a7fe..823f834c 100755
--- a/inc/poche/Database.class.php
+++ b/inc/poche/Database.class.php
@@ -411,10 +411,22 @@ class Database {
411 411
412 return $count; 412 return $count;
413 } 413 }
414 public function getRandomId($user_id) { 414 public function getRandomId($user_id, $view) {
415 $random = (STORAGE == 'mysql') ? 'RAND()' : 'RANDOM()'; 415 $random = (STORAGE == 'mysql') ? 'RAND()' : 'RANDOM()';
416 $sql = "SELECT id FROM entries WHERE user_id=? ORDER BY ". $random . " LIMIT 1"; 416 switch ($view) {
417 $params = array($user_id); 417 case 'archive':
418 $sql = "SELECT id FROM entries WHERE user_id=? AND is_read=? ORDER BY ". $random . " LIMIT 1";
419 $params = array($user_id,1);
420 break;
421 case 'fav':
422 $sql = "SELECT id FROM entries WHERE user_id=? AND is_fav=? ORDER BY ". $random . " LIMIT 1";
423 $params = array($user_id,1);
424 break;
425 default:
426 $sql = "SELECT id FROM entries WHERE user_id=? AND is_read=? ORDER BY ". $random . " LIMIT 1";
427 $params = array($user_id,0);
428 break;
429 }
418 $query = $this->executeQuery($sql, $params); 430 $query = $this->executeQuery($sql, $params);
419 $id = $query->fetchAll(); 431 $id = $query->fetchAll();
420 432