X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=inc%2Fpoche%2FDatabase.class.php;h=210ebb74cc279b0f55d61cced87dd46108f36206;hb=refs%2Ftags%2F1.9beta2;hp=6bac0f5d0e76d54b186d3b7fb33682ff150bd220;hpb=57068585c0a1164f1ae7ae399f3d5a68a4e9d46d;p=github%2Fwallabag%2Fwallabag.git diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index 6bac0f5d..210ebb74 100755 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php @@ -31,10 +31,15 @@ class Database { $this->handle = new PDO($db_path); break; case 'mysql': - $db_path = 'mysql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB . ';charset=utf8mb4'; - $this->handle = new PDO($db_path, STORAGE_USER, STORAGE_PASSWORD, array( - PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', - )); + if (MYSQL_USE_UTF8MB4) { + $db_path = 'mysql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB . ';charset=utf8mb4'; + $this->handle = new PDO($db_path, STORAGE_USER, STORAGE_PASSWORD, array( + PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', + )); + } else { + $db_path = 'mysql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB; + $this->handle = new PDO($db_path, STORAGE_USER, STORAGE_PASSWORD); + } break; case 'postgres': $db_path = 'pgsql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB; @@ -406,6 +411,14 @@ class Database { return $count; } + public function getRandomId($row, $user_id) { + $sql = "SELECT id FROM entries WHERE user_id=? LIMIT 1 OFFSET ? "; + $params = array($user_id, $row); + $query = $this->executeQuery($sql, $params); + + return $query->fetchAll(); + } + public function updateContent($id, $content, $user_id) {