johannes                                 Wed, 31 Aug 2011 20:30:08 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=315933

Log:
- Register extensions using mysqlnd (mysql, myslqi, pdo_mysql) with mysqlnd

Changed paths:
    U   php/php-src/branches/PHP_5_4/ext/mysql/php_mysql.c
    U   php/php-src/branches/PHP_5_4/ext/mysqli/mysqli.c
    U   php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd.c
    U   php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd.h
    U   php/php-src/branches/PHP_5_4/ext/mysqlnd/php_mysqlnd.c
    U   php/php-src/branches/PHP_5_4/ext/pdo_mysql/pdo_mysql.c
    U   php/php-src/trunk/ext/mysql/php_mysql.c
    U   php/php-src/trunk/ext/mysqli/mysqli.c
    U   php/php-src/trunk/ext/mysqlnd/mysqlnd.c
    U   php/php-src/trunk/ext/mysqlnd/mysqlnd.h
    U   php/php-src/trunk/ext/mysqlnd/php_mysqlnd.c
    U   php/php-src/trunk/ext/pdo_mysql/pdo_mysql.c

Modified: php/php-src/branches/PHP_5_4/ext/mysql/php_mysql.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/mysql/php_mysql.c	2011-08-31 20:28:08 UTC (rev 315932)
+++ php/php-src/branches/PHP_5_4/ext/mysql/php_mysql.c	2011-08-31 20:30:08 UTC (rev 315933)
@@ -529,6 +529,31 @@
 }
 /* }}} */

+#ifdef MYSQL_USE_MYSQLND
+static MYSQLND *mysql_convert_zv_to_mysqlnd(zval *zv)
+{
+	php_mysql_conn *mysql;
+
+	if (Z_TYPE_P(zv) != IS_RESOURCE) {
+		/* Might be nicer to check resource type, too, but ext/mysql is the only one using resources so emitting an error is not to bad, while usually this hook should be silent */
+		return NULL;
+	}
+
+	mysql = (php_mysql_conn *)zend_fetch_resource(&zv TSRMLS_CC, -1, "MySQL-Link", NULL, 2, le_link, le_plink);
+
+	if (!mysql) {
+		return NULL;
+	}
+
+	return mysql->conn;
+}
+
+static mysqlnd_api_extension_t mysqlnd_api_ext = {
+	&mysql_module_entry,
+	mysql_convert_zv_to_mysqlnd
+};
+#endif
+
 /* {{{ PHP_MINIT_FUNCTION
  */
 ZEND_MODULE_STARTUP_D(mysql)
@@ -557,6 +582,10 @@
 #endif
 #endif

+#ifdef MYSQL_USE_MYSQLND
+	mysqlnd_register_api_extension(&mysqlnd_api_ext);
+#endif
+
 	return SUCCESS;
 }
 /* }}} */

Modified: php/php-src/branches/PHP_5_4/ext/mysqli/mysqli.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/mysqli/mysqli.c	2011-08-31 20:28:08 UTC (rev 315932)
+++ php/php-src/branches/PHP_5_4/ext/mysqli/mysqli.c	2011-08-31 20:30:08 UTC (rev 315933)
@@ -30,6 +30,7 @@
 #include "php_ini.h"
 #include "ext/standard/info.h"
 #include "ext/standard/php_string.h"
+#include "php_mysqli.h"
 #include "php_mysqli_structs.h"
 #include "mysqli_priv.h"
 #include "zend_exceptions.h"
@@ -526,7 +527,30 @@
 }
 /* }}} */

+#ifdef MYSQLI_USE_MYSQLND
+static MYSQLND *mysqli_convert_zv_to_mysqlnd(zval *zv)
+{
+	if (Z_TYPE_P(zv) == IS_OBJECT && Z_OBJCE_P(zv) == mysqli_link_class_entry) {
+		MY_MYSQL *mysql;
+		MYSQLI_RESOURCE  *my_res;
+		mysqli_object *intern = (mysqli_object *)zend_object_store_get_object(zv TSRMLS_CC);
+		if (!(my_res = (MYSQLI_RESOURCE *)intern->ptr)) {
+			/* We know that we have a mysqli object, so this failure should be emitted */
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", intern->zo.ce->name);
+			return NULL;
+		}
+		mysql = ((MY_MYSQL *)my_res->ptr)->mysql;
+		return mysql ? mysql->mysql : NULL;
+	}
+	return NULL;
+}

+static mysqlnd_api_extension_t mysqli_api_ext = {
+	&mysqli_module_entry,
+	mysqli_convert_zv_to_mysqlnd
+};
+#endif
+
 /* {{{ PHP_INI_BEGIN
 */
 PHP_INI_BEGIN()
@@ -813,6 +837,11 @@
 	REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_BACKUP_LOG", REFRESH_BACKUP_LOG, CONST_CS | CONST_PERSISTENT);
 #endif

+
+#ifdef MYSQL_USE_MYSQLND
+	mysqlnd_register_api_extension(&mysqli_api_ext);
+#endif
+
 	return SUCCESS;
 }
 /* }}} */

Modified: php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd.c	2011-08-31 20:28:08 UTC (rev 315932)
+++ php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd.c	2011-08-31 20:30:08 UTC (rev 315933)
@@ -68,6 +68,7 @@

 static struct st_mysqlnd_plugin_core mysqlnd_plugin_core;

+static HashTable mysqlnd_api_ext_ht;

 /* {{{ mysqlnd_error_list_pdtor */
 static void
@@ -92,6 +93,7 @@
 		mysqlnd_stats_end(mysqlnd_global_stats);
 		mysqlnd_global_stats = NULL;
 		mysqlnd_library_initted = FALSE;
+		zend_hash_destroy(&mysqlnd_api_ext_ht);
 	}
 }
 /* }}} */
@@ -2542,11 +2544,47 @@
 		mysqlnd_example_plugin_register(TSRMLS_C);
 		mysqlnd_debug_trace_plugin_register(TSRMLS_C);
 		mysqlnd_register_builtin_authentication_plugins(TSRMLS_C);
+
+		zend_hash_init(&mysqlnd_api_ext_ht, 3, NULL, NULL, 1);
 	}
 }
 /* }}} */

+/* {{{ myslqnd_get_api_extensions */
+PHPAPI HashTable *mysqlnd_get_api_extensions()
+{
+	return &mysqlnd_api_ext_ht;
+}
+/* }}} */

+/* {{{ mysqlnd_register_api_extension */
+PHPAPI void mysqlnd_register_api_extension(mysqlnd_api_extension_t *apiext)
+{
+	zend_hash_add(&mysqlnd_api_ext_ht, apiext->module->name, strlen(apiext->module->name)+1, &apiext, sizeof(mysqlnd_api_extension_t), NULL);
+}
+/* }}} */
+
+/* {{{ zval_to_mysqlnd */
+PHPAPI MYSQLND* zval_to_mysqlnd(zval *zv)
+{
+	MYSQLND* retval;
+	mysqlnd_api_extension_t **elem;
+
+	for (zend_hash_internal_pointer_reset(&mysqlnd_api_ext_ht);
+			zend_hash_get_current_data(&mysqlnd_api_ext_ht, (void **)&elem) == SUCCESS;
+			zend_hash_move_forward(&mysqlnd_api_ext_ht)) {
+		if ((*elem)->conversion_cb) {
+			retval = (*elem)->conversion_cb(zv);
+			if (retval) {
+				return retval;
+			}
+		}
+	}
+
+	return NULL;
+}
+/* }}} */
+
 /* {{{ mysqlnd_conn_get_methods */
 PHPAPI struct st_mysqlnd_conn_methods * mysqlnd_conn_get_methods()
 {

Modified: php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd.h
===================================================================
--- php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd.h	2011-08-31 20:28:08 UTC (rev 315932)
+++ php/php-src/branches/PHP_5_4/ext/mysqlnd/mysqlnd.h	2011-08-31 20:30:08 UTC (rev 315933)
@@ -310,6 +310,15 @@

 PHPAPI void mysqlnd_minfo_print_hash(zval *values);

+typedef struct {
+	zend_module_entry *module;
+	MYSQLND *(*conversion_cb)(zval *zv);
+} mysqlnd_api_extension_t;
+
+PHPAPI HashTable *mysqlnd_get_api_extensions();
+PHPAPI void mysqlnd_register_api_extension(mysqlnd_api_extension_t *apiext);
+PHPAPI MYSQLND* zval_to_mysqlnd(zval *zv);
+
 #endif	/* MYSQLND_H */



Modified: php/php-src/branches/PHP_5_4/ext/mysqlnd/php_mysqlnd.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/mysqlnd/php_mysqlnd.c	2011-08-31 20:28:08 UTC (rev 315932)
+++ php/php-src/branches/PHP_5_4/ext/mysqlnd/php_mysqlnd.c	2011-08-31 20:30:08 UTC (rev 315933)
@@ -133,7 +133,21 @@
 }
 /* }}} */

+/* {{{ mysqlnd_minfo_dump_api_plugins */
+static int
+mysqlnd_minfo_dump_api_plugins(void *pDest, void * buf TSRMLS_DC)
+{
+	smart_str * buffer = (smart_str *) buf;
+	mysqlnd_api_extension_t *ext = *(mysqlnd_api_extension_t **) pDest;
+	if (buffer->len) {
+		smart_str_appendc(buffer, ',');
+	}
+	smart_str_appends(buffer, ext->module->name);
+	return ZEND_HASH_APPLY_KEEP;
+}
+/* }}} */

+
 /* {{{ PHP_MINFO_FUNCTION
  */
 PHP_MINFO_FUNCTION(mysqlnd)
@@ -165,7 +179,6 @@
 	php_info_print_table_row(2, "Collecting memory statistics", MYSQLND_G(collect_memory_statistics)? "Yes":"No");

 	php_info_print_table_row(2, "Tracing", MYSQLND_G(debug)? MYSQLND_G(debug):"n/a");
-	php_info_print_table_end();

 	/* loaded plugins */
 	{
@@ -174,8 +187,16 @@
 		smart_str_0(&tmp_str);
 		php_info_print_table_row(2, "Loaded plugins", tmp_str.c);
 		smart_str_free(&tmp_str);
+
+		zend_hash_apply_with_argument(mysqlnd_get_api_extensions(), mysqlnd_minfo_dump_api_plugins, &tmp_str);
+		smart_str_0(&tmp_str);
+		php_info_print_table_row(2, "API Extensions", tmp_str.c);
+		smart_str_free(&tmp_str);
 	}

+	php_info_print_table_end();
+
+
 	/* Print client stats */
 	mysqlnd_plugin_apply_with_argument(mysqlnd_minfo_dump_plugin_stats, NULL);
 }

Modified: php/php-src/branches/PHP_5_4/ext/pdo_mysql/pdo_mysql.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/pdo_mysql/pdo_mysql.c	2011-08-31 20:28:08 UTC (rev 315932)
+++ php/php-src/branches/PHP_5_4/ext/pdo_mysql/pdo_mysql.c	2011-08-31 20:30:08 UTC (rev 315933)
@@ -47,6 +47,29 @@
 # endif
 #endif

+#ifdef PDO_USE_MYSQLND
+static MYSQLND *pdo_mysql_convert_zv_to_mysqlnd(zval *zv)
+{
+	if (Z_TYPE_P(zv) == IS_OBJECT && Z_OBJCE_P(zv) == php_pdo_get_dbh_ce()) {
+		pdo_dbh_t *dbh = zend_object_store_get_object(zv TSRMLS_CC);
+
+		if (!dbh || dbh->driver != &pdo_mysql_driver) {
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Provided PDO instance is not using MySQL but %s", dbh->driver->driver_name);
+			return NULL;
+		}
+
+		return ((pdo_mysql_db_handle *)dbh)->server;
+	}
+	return NULL;
+}
+
+static mysqlnd_api_extension_t pdo_mysql_api_ext = {
+	&pdo_mysql_module_entry,
+	pdo_mysql_convert_zv_to_mysqlnd
+};
+#endif
+
+
 /* {{{ PHP_INI_BEGIN
 */
 PHP_INI_BEGIN()
@@ -84,6 +107,11 @@
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CA", (long)PDO_MYSQL_ATTR_SSL_CA);
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CAPATH", (long)PDO_MYSQL_ATTR_SSL_CAPATH);
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CIPHER", (long)PDO_MYSQL_ATTR_SSL_CIPHER);
+
+#ifdef PDO_USE_MYSQLND
+	mysqlnd_register_api_extension(&pdo_mysql_api_ext);
+#endif
+
 	return php_pdo_register_driver(&pdo_mysql_driver);
 }
 /* }}} */

Modified: php/php-src/trunk/ext/mysql/php_mysql.c
===================================================================
--- php/php-src/trunk/ext/mysql/php_mysql.c	2011-08-31 20:28:08 UTC (rev 315932)
+++ php/php-src/trunk/ext/mysql/php_mysql.c	2011-08-31 20:30:08 UTC (rev 315933)
@@ -529,6 +529,31 @@
 }
 /* }}} */

+#ifdef MYSQL_USE_MYSQLND
+static MYSQLND *mysql_convert_zv_to_mysqlnd(zval *zv)
+{
+	php_mysql_conn *mysql;
+
+	if (Z_TYPE_P(zv) != IS_RESOURCE) {
+		/* Might be nicer to check resource type, too, but ext/mysql is the only one using resources so emitting an error is not to bad, while usually this hook should be silent */
+		return NULL;
+	}
+
+	mysql = (php_mysql_conn *)zend_fetch_resource(&zv TSRMLS_CC, -1, "MySQL-Link", NULL, 2, le_link, le_plink);
+
+	if (!mysql) {
+		return NULL;
+	}
+
+	return mysql->conn;
+}
+
+static mysqlnd_api_extension_t mysqlnd_api_ext = {
+	&mysql_module_entry,
+	mysql_convert_zv_to_mysqlnd
+};
+#endif
+
 /* {{{ PHP_MINIT_FUNCTION
  */
 ZEND_MODULE_STARTUP_D(mysql)
@@ -557,6 +582,10 @@
 #endif
 #endif

+#ifdef MYSQL_USE_MYSQLND
+	mysqlnd_register_api_extension(&mysqlnd_api_ext);
+#endif
+
 	return SUCCESS;
 }
 /* }}} */

Modified: php/php-src/trunk/ext/mysqli/mysqli.c
===================================================================
--- php/php-src/trunk/ext/mysqli/mysqli.c	2011-08-31 20:28:08 UTC (rev 315932)
+++ php/php-src/trunk/ext/mysqli/mysqli.c	2011-08-31 20:30:08 UTC (rev 315933)
@@ -30,6 +30,7 @@
 #include "php_ini.h"
 #include "ext/standard/info.h"
 #include "ext/standard/php_string.h"
+#include "php_mysqli.h"
 #include "php_mysqli_structs.h"
 #include "mysqli_priv.h"
 #include "zend_exceptions.h"
@@ -526,7 +527,30 @@
 }
 /* }}} */

+#ifdef MYSQLI_USE_MYSQLND
+static MYSQLND *mysqli_convert_zv_to_mysqlnd(zval *zv)
+{
+	if (Z_TYPE_P(zv) == IS_OBJECT && Z_OBJCE_P(zv) == mysqli_link_class_entry) {
+		MY_MYSQL *mysql;
+		MYSQLI_RESOURCE  *my_res;
+		mysqli_object *intern = (mysqli_object *)zend_object_store_get_object(zv TSRMLS_CC);
+		if (!(my_res = (MYSQLI_RESOURCE *)intern->ptr)) {
+			/* We know that we have a mysqli object, so this failure should be emitted */
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", intern->zo.ce->name);
+			return NULL;
+		}
+		mysql = ((MY_MYSQL *)my_res->ptr)->mysql;
+		return mysql ? mysql->mysql : NULL;
+	}
+	return NULL;
+}

+static mysqlnd_api_extension_t mysqli_api_ext = {
+	&mysqli_module_entry,
+	mysqli_convert_zv_to_mysqlnd
+};
+#endif
+
 /* {{{ PHP_INI_BEGIN
 */
 PHP_INI_BEGIN()
@@ -813,6 +837,11 @@
 	REGISTER_LONG_CONSTANT("MYSQLI_REFRESH_BACKUP_LOG", REFRESH_BACKUP_LOG, CONST_CS | CONST_PERSISTENT);
 #endif

+
+#ifdef MYSQL_USE_MYSQLND
+	mysqlnd_register_api_extension(&mysqli_api_ext);
+#endif
+
 	return SUCCESS;
 }
 /* }}} */

Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd.c	2011-08-31 20:28:08 UTC (rev 315932)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd.c	2011-08-31 20:30:08 UTC (rev 315933)
@@ -68,6 +68,7 @@

 static struct st_mysqlnd_plugin_core mysqlnd_plugin_core;

+static HashTable mysqlnd_api_ext_ht;

 /* {{{ mysqlnd_error_list_pdtor */
 static void
@@ -92,6 +93,7 @@
 		mysqlnd_stats_end(mysqlnd_global_stats);
 		mysqlnd_global_stats = NULL;
 		mysqlnd_library_initted = FALSE;
+		zend_hash_destroy(&mysqlnd_api_ext_ht);
 	}
 }
 /* }}} */
@@ -2542,11 +2544,47 @@
 		mysqlnd_example_plugin_register(TSRMLS_C);
 		mysqlnd_debug_trace_plugin_register(TSRMLS_C);
 		mysqlnd_register_builtin_authentication_plugins(TSRMLS_C);
+
+		zend_hash_init(&mysqlnd_api_ext_ht, 3, NULL, NULL, 1);
 	}
 }
 /* }}} */

+/* {{{ myslqnd_get_api_extensions */
+PHPAPI HashTable *mysqlnd_get_api_extensions()
+{
+	return &mysqlnd_api_ext_ht;
+}
+/* }}} */

+/* {{{ mysqlnd_register_api_extension */
+PHPAPI void mysqlnd_register_api_extension(mysqlnd_api_extension_t *apiext)
+{
+	zend_hash_add(&mysqlnd_api_ext_ht, apiext->module->name, strlen(apiext->module->name)+1, &apiext, sizeof(mysqlnd_api_extension_t), NULL);
+}
+/* }}} */
+
+/* {{{ zval_to_mysqlnd */
+PHPAPI MYSQLND* zval_to_mysqlnd(zval *zv)
+{
+	MYSQLND* retval;
+	mysqlnd_api_extension_t **elem;
+
+	for (zend_hash_internal_pointer_reset(&mysqlnd_api_ext_ht);
+			zend_hash_get_current_data(&mysqlnd_api_ext_ht, (void **)&elem) == SUCCESS;
+			zend_hash_move_forward(&mysqlnd_api_ext_ht)) {
+		if ((*elem)->conversion_cb) {
+			retval = (*elem)->conversion_cb(zv);
+			if (retval) {
+				return retval;
+			}
+		}
+	}
+
+	return NULL;
+}
+/* }}} */
+
 /* {{{ mysqlnd_conn_get_methods */
 PHPAPI struct st_mysqlnd_conn_methods * mysqlnd_conn_get_methods()
 {

Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd.h
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd.h	2011-08-31 20:28:08 UTC (rev 315932)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd.h	2011-08-31 20:30:08 UTC (rev 315933)
@@ -310,6 +310,15 @@

 PHPAPI void mysqlnd_minfo_print_hash(zval *values);

+typedef struct {
+	zend_module_entry *module;
+	MYSQLND *(*conversion_cb)(zval *zv);
+} mysqlnd_api_extension_t;
+
+PHPAPI HashTable *mysqlnd_get_api_extensions();
+PHPAPI void mysqlnd_register_api_extension(mysqlnd_api_extension_t *apiext);
+PHPAPI MYSQLND* zval_to_mysqlnd(zval *zv);
+
 #endif	/* MYSQLND_H */



Modified: php/php-src/trunk/ext/mysqlnd/php_mysqlnd.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/php_mysqlnd.c	2011-08-31 20:28:08 UTC (rev 315932)
+++ php/php-src/trunk/ext/mysqlnd/php_mysqlnd.c	2011-08-31 20:30:08 UTC (rev 315933)
@@ -133,7 +133,21 @@
 }
 /* }}} */

+/* {{{ mysqlnd_minfo_dump_api_plugins */
+static int
+mysqlnd_minfo_dump_api_plugins(void *pDest, void * buf TSRMLS_DC)
+{
+	smart_str * buffer = (smart_str *) buf;
+	mysqlnd_api_extension_t *ext = *(mysqlnd_api_extension_t **) pDest;
+	if (buffer->len) {
+		smart_str_appendc(buffer, ',');
+	}
+	smart_str_appends(buffer, ext->module->name);
+	return ZEND_HASH_APPLY_KEEP;
+}
+/* }}} */

+
 /* {{{ PHP_MINFO_FUNCTION
  */
 PHP_MINFO_FUNCTION(mysqlnd)
@@ -165,7 +179,6 @@
 	php_info_print_table_row(2, "Collecting memory statistics", MYSQLND_G(collect_memory_statistics)? "Yes":"No");

 	php_info_print_table_row(2, "Tracing", MYSQLND_G(debug)? MYSQLND_G(debug):"n/a");
-	php_info_print_table_end();

 	/* loaded plugins */
 	{
@@ -174,8 +187,16 @@
 		smart_str_0(&tmp_str);
 		php_info_print_table_row(2, "Loaded plugins", tmp_str.c);
 		smart_str_free(&tmp_str);
+
+		zend_hash_apply_with_argument(mysqlnd_get_api_extensions(), mysqlnd_minfo_dump_api_plugins, &tmp_str);
+		smart_str_0(&tmp_str);
+		php_info_print_table_row(2, "API Extensions", tmp_str.c);
+		smart_str_free(&tmp_str);
 	}

+	php_info_print_table_end();
+
+
 	/* Print client stats */
 	mysqlnd_plugin_apply_with_argument(mysqlnd_minfo_dump_plugin_stats, NULL);
 }

Modified: php/php-src/trunk/ext/pdo_mysql/pdo_mysql.c
===================================================================
--- php/php-src/trunk/ext/pdo_mysql/pdo_mysql.c	2011-08-31 20:28:08 UTC (rev 315932)
+++ php/php-src/trunk/ext/pdo_mysql/pdo_mysql.c	2011-08-31 20:30:08 UTC (rev 315933)
@@ -47,6 +47,29 @@
 # endif
 #endif

+#ifdef PDO_USE_MYSQLND
+static MYSQLND *pdo_mysql_convert_zv_to_mysqlnd(zval *zv)
+{
+	if (Z_TYPE_P(zv) == IS_OBJECT && Z_OBJCE_P(zv) == php_pdo_get_dbh_ce()) {
+		pdo_dbh_t *dbh = zend_object_store_get_object(zv TSRMLS_CC);
+
+		if (!dbh || dbh->driver != &pdo_mysql_driver) {
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Provided PDO instance is not using MySQL but %s", dbh->driver->driver_name);
+			return NULL;
+		}
+
+		return ((pdo_mysql_db_handle *)dbh)->server;
+	}
+	return NULL;
+}
+
+static mysqlnd_api_extension_t pdo_mysql_api_ext = {
+	&pdo_mysql_module_entry,
+	pdo_mysql_convert_zv_to_mysqlnd
+};
+#endif
+
+
 /* {{{ PHP_INI_BEGIN
 */
 PHP_INI_BEGIN()
@@ -84,6 +107,11 @@
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CA", (long)PDO_MYSQL_ATTR_SSL_CA);
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CAPATH", (long)PDO_MYSQL_ATTR_SSL_CAPATH);
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CIPHER", (long)PDO_MYSQL_ATTR_SSL_CIPHER);
+
+#ifdef PDO_USE_MYSQLND
+	mysqlnd_register_api_extension(&pdo_mysql_api_ext);
+#endif
+
 	return php_pdo_register_driver(&pdo_mysql_driver);
 }
 /* }}} */
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to