From b668db242de35f13de0b317ceaa209574458e9c8 Mon Sep 17 00:00:00 2001 From: Robert Ros Date: Thu, 18 Sep 2014 21:33:22 +0200 Subject: Convert the MySQL charset to utf8mb4 to support the full range of unicode characters --- inc/poche/Database.class.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'inc/poche') diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index dfd7ae34..7aaf9740 100755 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php @@ -24,15 +24,17 @@ class Database { switch (STORAGE) { case 'sqlite': // Check if /db is writeable - if ( !is_writable(STORAGE_SQLITE) || !is_writable(dirname(STORAGE_SQLITE))) { + 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; -- cgit v1.2.3