From 97851842db529f1905aa3dacba0527409535e776 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sun, 9 Jun 2013 00:02:04 +0300 Subject: [PATCH] set charset on mysql only --- ipf/orm/connection.php | 12 +++++++----- ipf/orm/connection/mysql.php | 15 ++++----------- ipf/orm/manager.php | 1 - 3 files changed, 11 insertions(+), 17 deletions(-) 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; -- 2.49.0