summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS4
-rwxr-xr-xUPGRADING2
-rwxr-xr-xext/pdo_mysql/mysql_driver.c7
-rwxr-xr-xext/pdo_mysql/php_pdo_mysql_int.h4
4 files changed, 17 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index c8d186dd61..a21a7c27b2 100644
--- 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.
diff --git a/UPGRADING b/UPGRADING
index b590324764..25a67979cc 100755
--- 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.
===================================
diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c
index 7540503d38..b04a17866d 100755
--- a/ext/pdo_mysql/mysql_driver.c
+++ b/ext/pdo_mysql/mysql_driver.c
@@ -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);
}
diff --git a/ext/pdo_mysql/php_pdo_mysql_int.h b/ext/pdo_mysql/php_pdo_mysql_int.h
index b0c5ebdb1f..839b3ae137 100755
--- a/ext/pdo_mysql/php_pdo_mysql_int.h
+++ b/ext/pdo_mysql/php_pdo_mysql_int.h
@@ -33,6 +33,10 @@
# 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