]> granicus.if.org Git - php/commitdiff
Implemented FR #47802, support for character sets in DSN strings for PDO_MYSQL
authorKalle Sommer Nielsen <kalle@php.net>
Fri, 7 Jan 2011 14:39:56 +0000 (14:39 +0000)
committerKalle Sommer Nielsen <kalle@php.net>
Fri, 7 Jan 2011 14:39:56 +0000 (14:39 +0000)
NEWS
UPGRADING
ext/pdo_mysql/mysql_driver.c
ext/pdo_mysql/php_pdo_mysql_int.h

diff --git a/NEWS b/NEWS
index c8d186dd61326a4815a94751ca4a4ec68637f270..a21a7c27b2e9185b08b1d4cc64554b82b355a236 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -170,6 +170,10 @@ PHP                                                                        NEWS
   . Added nextRowset support.
   . Fixed bug #50755 (PDO DBLIB Fails with OOM).
 
+- Improved PDO MySQL:
+  . Implemented FR #47802 (Support for setting character sets in DSN strings). 
+    (Kalle)
+
 - Improved Reflection extension: (Johannes)
   . Added ReflectionExtension::isTemporary() and
     ReflectionExtension::isPersistent() methods.
index b590324764cb608ab8af0219321d5a47054d3933..25a67979cc982f1c34898042758f231a9a8688a5 100755 (executable)
--- a/UPGRADING
+++ b/UPGRADING
@@ -161,6 +161,8 @@ UPGRADE NOTES - PHP X.Y
   strings. This breaks code that iterated the resulting stream array using a
   numeric index, but makes easier to identify which of the passed streams are
   present in the result.
+- pdo_mysql now supports setting character sets when connecting in the DSN 
+  string.
  
 
 ===================================
index 7540503d38a5e7d30f4c27ab1132bf10ae94063a..b04a17866d2e9eab62e6c2b82ee05948d3d1a80e 100755 (executable)
@@ -711,6 +711,13 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
                goto cleanup;
        }
 
+#ifdef PDO_MYSQL_HAS_CHARSET
+       if (vars[0].optval && mysql_set_character_set(H->server, vars[0].optval)) {
+               pdo_mysql_error(dbh);
+               goto cleanup;
+       }
+#endif
+
        if (!dbh->auto_commit) {
                mysql_handle_autocommit(dbh TSRMLS_CC);
        }
index b0c5ebdb1ff55cf21566c67348f3e781cf940373..839b3ae137cef86156ee8e017bb01aa09fa25eb3 100755 (executable)
 #      define PDO_MYSQL_PARAM_BIND MYSQL_BIND
 #endif
 
+#if (MYSQL_VERSION_ID >= 40113 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID >= 50007 || defined(MYSQL_USE_MYSQLND)
+# define PDO_MYSQL_HAS_CHARSET
+#endif
+
 #if defined(PDO_USE_MYSQLND) && PHP_DEBUG && !defined(PHP_WIN32)
 #define PDO_DBG_ENABLED 1