From: Andrey Kutejko Date: Sat, 8 Jun 2013 21:02:04 +0000 (+0300) Subject: set charset on mysql only X-Git-Tag: 0.5~256 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=97851842db529f1905aa3dacba0527409535e776;p=ipf.git set charset on mysql only --- diff --git a/ipf/orm/connection.php b/ipf/orm/connection.php index 7956948..351c75d 100644 --- a/ipf/orm/connection.php +++ b/ipf/orm/connection.php @@ -240,10 +240,16 @@ abstract class IPF_ORM_Connection extends IPF_ORM_Configurable implements Counta $this->isConnected = true; + $this->onConnect(); + $this->notifyDBListeners('postConnect', $event); return true; } - + + protected function onConnect() + { + } + public function incrementQueryCount() { $this->_count++; @@ -355,10 +361,6 @@ abstract class IPF_ORM_Connection extends IPF_ORM_Configurable implements Counta return $this->exec($query, array_values($fields)); } - public function setCharset($charset) - { - } - public function quoteIdentifier($str, $checkOption = true) { // quick fix for the identifiers that contain a dot diff --git a/ipf/orm/connection/mysql.php b/ipf/orm/connection/mysql.php index 4177841..dba7082 100644 --- a/ipf/orm/connection/mysql.php +++ b/ipf/orm/connection/mysql.php @@ -48,24 +48,17 @@ class IPF_ORM_Connection_Mysql extends IPF_ORM_Connection parent::__construct($manager, $adapter); } - public function connect() + protected function onConnect() { - $connected = parent::connect(); $this->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); - return $connected; + $this->exec('SET NAMES \'utf8\''); } - + public function getDatabaseName() { return $this->fetchOne('SELECT DATABASE()'); } - public function setCharset($charset) - { - $query = 'SET NAMES ' . $this->quote($charset); - $this->exec($query); - } - public function replace(IPF_ORM_Table $table, array $fields, array $keys) { if (empty($keys)) { @@ -97,4 +90,4 @@ class IPF_ORM_Connection_Mysql extends IPF_ORM_Connection } return $query; } -} \ No newline at end of file +} diff --git a/ipf/orm/manager.php b/ipf/orm/manager.php index a8bdfe8..0afa67e 100644 --- a/ipf/orm/manager.php +++ b/ipf/orm/manager.php @@ -128,7 +128,6 @@ class IPF_ORM_Manager extends IPF_ORM_Configurable implements Countable, Iterato if ($persistent) $conn->setOption(IPF_ORM::ATTR_PERSISTENT, true); $conn->setName($name); - $conn->setCharset('utf8'); $this->_connections[$name] = $conn;