[icinga-checkins] icinga.org: icingaweb2/master: DbConnection: fix utf8-encoded MySQL connections

git at icinga.org git at icinga.org
Mon Feb 29 20:59:06 CET 2016


Module: icingaweb2
Branch: master
Commit: 1fba49116062faaa3d910a87f56daf233e523d19
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=1fba49116062faaa3d910a87f56daf233e523d19

Author: Thomas Gelf <thomas at gelf.net>
Date:   Mon Feb 29 20:58:34 2016 +0100

DbConnection: fix utf8-encoded MySQL connections

---

 library/Icinga/Data/Db/DbConnection.php |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/library/Icinga/Data/Db/DbConnection.php b/library/Icinga/Data/Db/DbConnection.php
index 4dd69ce..f643d48 100644
--- a/library/Icinga/Data/Db/DbConnection.php
+++ b/library/Icinga/Data/Db/DbConnection.php
@@ -153,6 +153,11 @@ class DbConnection implements Selectable, Extensible, Updatable, Reducible, Insp
                 $driverOptions[PDO::MYSQL_ATTR_INIT_COMMAND] =
                     'SET SESSION SQL_MODE=\'STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,'
                     . 'NO_AUTO_CREATE_USER,ANSI_QUOTES,PIPES_AS_CONCAT,NO_ENGINE_SUBSTITUTION\';';
+                if (array_key_exists('charset', $adapterParamaters) && $adapterParamaters['charset']) {
+                    $driverOptions[PDO::MYSQL_ATTR_INIT_COMMAND] .= 'SET NAMES ' . $adapterParamaters['charset']. ';';
+                    unset($adapterParamaters['charset']);
+                }
+
                 $adapterParamaters['port'] = $this->config->get('port', 3306);
                 break;
             case 'oci':



More information about the icinga-checkins mailing list