summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2014-10-06 19:26:37 +0200
committerSimon Rettberg2014-10-06 19:26:37 +0200
commit365003d0d8f6bf05852ddbd9a1f2ffd992ac3d71 (patch)
tree2400efea7569c02f1fc9085ab96e8a626dbe50a1
parentMove baseconfig translations according to template move (diff)
downloadslx-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.example2
-rw-r--r--inc/database.inc.php5
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());
}