]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - inc/poche/Database.class.php
from spaces to commas
[github/wallabag/wallabag.git] / inc / poche / Database.class.php
index 8b52a9df840f8999798161b93ac8aa96bcced8e4..f6ba47089e8b1cb5b5a87d08787cf0b30397aefc 100755 (executable)
@@ -23,12 +23,18 @@ class Database {
     {
         switch (STORAGE) {
             case 'sqlite':
+                // Check if /db is writeable
+                if ( !is_writable(STORAGE_SQLITE) || !is_writable(dirname(STORAGE_SQLITE))) {
+                       die('An error occured: "db" directory must be writeable for your web server user!');
+                }
                 $db_path = 'sqlite:' . STORAGE_SQLITE;
                 $this->handle = new PDO($db_path);
                 break;
             case 'mysql':
-                $db_path = 'mysql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB;
-                $this->handle = new PDO($db_path, STORAGE_USER, STORAGE_PASSWORD);
+                $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',
+                ));
                 break;
             case 'postgres':
                 $db_path = 'pgsql:host=' . STORAGE_SERVER . ';dbname=' . STORAGE_DB;