]> git.andy128k.dev Git - ipf.git/commitdiff
set charset on mysql only
authorAndrey Kutejko <andy128k@gmail.com>
Sat, 8 Jun 2013 21:02:04 +0000 (00:02 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sat, 8 Jun 2013 21:02:04 +0000 (00:02 +0300)
ipf/orm/connection.php
ipf/orm/connection/mysql.php
ipf/orm/manager.php

index 79569489128abaeebeebed3136746c0e4df677a0..351c75d06ec083ee29e28665e1b9ce09210785fa 100644 (file)
@@ -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
index 4177841893d418c447d4bc315f735d7b3e78446e..dba70821f03c3a7277c92cd4257ec974226f1bc0 100644 (file)
@@ -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
+}
index a8bdfe8e230fc7c7206720f7a54f167d2f914156..0afa67ecdceb63b0c00de454b27ed270c3aa9b43 100644 (file)
@@ -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;