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.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