diff options
author | Simon Rettberg | 2014-10-06 19:26:37 +0200 |
---|---|---|
committer | Simon Rettberg | 2014-10-06 19:26:37 +0200 |
commit | 365003d0d8f6bf05852ddbd9a1f2ffd992ac3d71 (patch) | |
tree | 2400efea7569c02f1fc9085ab96e8a626dbe50a1 | |
parent | Move baseconfig translations according to template move (diff) | |
download | slx-admin-365003d0d8f6bf05852ddbd9a1f2ffd992ac3d71.tar.gz slx-admin-365003d0d8f6bf05852ddbd9a1f2ffd992ac3d71.tar.xz slx-admin-365003d0d8f6bf05852ddbd9a1f2ffd992ac3d71.zip |
Implement force utf8 option for mysql db
-rw-r--r-- | config.php.example | 2 | ||||
-rw-r--r-- | inc/database.inc.php | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/config.php.example b/config.php.example index 2e0ec117..1fded4da 100644 --- a/config.php.example +++ b/config.php.example @@ -11,7 +11,7 @@ define('CONFIG_SQL_DSN', 'mysql:dbname=openslx;host=localhost'); define('CONFIG_SQL_USER', 'openslx'); define('CONFIG_SQL_PASS', '%MYSQL_OPENSLX_PASS%'); // Set this to true if you mysql server doesn't default to UTF-8 on new connections -define('CONFIG_SQL_FORCE_UTF8', false); +define('CONFIG_SQL_FORCE_UTF8', true); define('CONFIG_TGZ_LIST_DIR', '/opt/openslx/configs'); diff --git a/inc/database.inc.php b/inc/database.inc.php index a729b7fc..0d48c23c 100644 --- a/inc/database.inc.php +++ b/inc/database.inc.php @@ -32,7 +32,10 @@ class Database if (self::$dbh !== false) return; try { - self::$dbh = new PDO(CONFIG_SQL_DSN, CONFIG_SQL_USER, CONFIG_SQL_PASS, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")); + if (CONFIG_SQL_FORCE_UTF8) + self::$dbh = new PDO(CONFIG_SQL_DSN, CONFIG_SQL_USER, CONFIG_SQL_PASS, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")); + else + self::$dbh = new PDO(CONFIG_SQL_DSN, CONFIG_SQL_USER, CONFIG_SQL_PASS); } catch (PDOException $e) { Util::traceError('Connecting to the local database failed: ' . $e->getMessage()); } |