andrey                                   Tue, 18 May 2010 11:50:31 +0000

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

Log:
Remove duplicated code.
Use one centralized functions for data extraction.

Changed paths:
    U   php/php-src/branches/PHP_5_3/ext/mysql/php_mysql.c
    U   php/php-src/branches/PHP_5_3/ext/mysqli/mysqli.c
    U   php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_api.c
    U   php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_nonapi.c
    U   php/php-src/trunk/ext/mysql/php_mysql.c
    U   php/php-src/trunk/ext/mysqli/mysqli_api.c
    U   php/php-src/trunk/ext/mysqli/mysqli_nonapi.c

Modified: php/php-src/branches/PHP_5_3/ext/mysql/php_mysql.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysql/php_mysql.c	2010-05-18 11:36:54 UTC (rev 299447)
+++ php/php-src/branches/PHP_5_3/ext/mysql/php_mysql.c	2010-05-18 11:50:31 UTC (rev 299448)
@@ -1993,7 +1993,7 @@
 		}
 	}
 #else
-	mysqlnd_fetch_into(mysql_result, MYSQLND_FETCH_ASSOC, return_value, MYSQLND_MYSQL);
+	mysqlnd_fetch_into(mysql_result, ((result_type & MYSQL_NUM)? MYSQLND_FETCH_NUM:0) | ((result_type & MYSQL_ASSOC)? MYSQLND_FETCH_ASSOC:0), return_value, MYSQLND_MYSQL);
 #endif

 #ifdef ZEND_ENGINE_2
@@ -2071,19 +2071,7 @@
    Gets a result row as an enumerated array */
 PHP_FUNCTION(mysql_fetch_row)
 {
-#ifdef MYSQL_USE_MYSQLND
-	MYSQL_RES		*result;
-	zval			*mysql_result;
-
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &mysql_result) == FAILURE) {
-		return;
-	}
-	ZEND_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, -1, "MySQL result", le_result);
-
-	mysqlnd_fetch_into(result, MYSQLND_FETCH_NUM, return_value, MYSQLND_MYSQL);
-#else
 	php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQL_NUM, 1, 0);
-#endif
 }
 /* }}} */

@@ -2105,25 +2093,7 @@
    Fetch a result row as an array (associative, numeric or both) */
 PHP_FUNCTION(mysql_fetch_array)
 {
-#ifndef MYSQL_USE_MYSQLND
 	php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0, 2, 0);
-#else
-	MYSQL_RES		*result;
-	zval			*mysql_result;
-	long			mode = MYSQLND_FETCH_BOTH;
-
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &mysql_result, &mode) == FAILURE) {
-		return;
-	}
-	ZEND_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, -1, "MySQL result", le_result);
-
-	if (mode & ~MYSQL_BOTH) {
-                php_error_docref(NULL TSRMLS_CC, E_WARNING, "The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH");
-                mode = MYSQL_BOTH;
-        }
-
-	mysqlnd_fetch_into(result, mode, return_value, MYSQLND_MYSQL);
-#endif
 }
 /* }}} */

@@ -2132,19 +2102,7 @@
    Fetch a result row as an associative array */
 PHP_FUNCTION(mysql_fetch_assoc)
 {
-#ifndef MYSQL_USE_MYSQLND
 	php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQL_ASSOC, 1, 0);
-#else
-	MYSQL_RES		*result;
-	zval			*mysql_result;
-
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &mysql_result) == FAILURE) {
-		return;
-	}
-	ZEND_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, -1, "MySQL result", le_result);
-
-	mysqlnd_fetch_into(result, MYSQLND_FETCH_ASSOC, return_value, MYSQLND_MYSQL);
-#endif
 }
 /* }}} */


Modified: php/php-src/branches/PHP_5_3/ext/mysqli/mysqli.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqli/mysqli.c	2010-05-18 11:36:54 UTC (rev 299447)
+++ php/php-src/branches/PHP_5_3/ext/mysqli/mysqli.c	2010-05-18 11:50:31 UTC (rev 299448)
@@ -1195,7 +1195,7 @@
 		}
 	}
 #else
-	mysqlnd_fetch_into(result, MYSQLND_FETCH_ASSOC, return_value, MYSQLND_MYSQLI);
+	mysqlnd_fetch_into(result, ((fetchtype & MYSQLI_NUM)? MYSQLND_FETCH_NUM:0) | ((fetchtype & MYSQLI_ASSOC)? MYSQLND_FETCH_ASSOC:0), return_value, MYSQLND_MYSQLI);
 #endif

 	if (into_object && Z_TYPE_P(return_value) != IS_NULL) {

Modified: php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_api.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_api.c	2010-05-18 11:36:54 UTC (rev 299447)
+++ php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_api.c	2010-05-18 11:50:31 UTC (rev 299448)
@@ -1148,18 +1148,7 @@
    Get a result row as an enumerated array */
 PHP_FUNCTION(mysqli_fetch_row)
 {
-#if !defined(MYSQLI_USE_MYSQLND)
 	php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQLI_NUM, 0);
-#else
-	MYSQL_RES	*result;
-	zval		*mysql_result;
-
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) {
-		return;
-	}
-	MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
-	mysqlnd_fetch_into(result, MYSQLND_FETCH_NUM, return_value, MYSQLND_MYSQLI);
-#endif
 }
 /* }}} */


Modified: php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_nonapi.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_nonapi.c	2010-05-18 11:36:54 UTC (rev 299447)
+++ php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_nonapi.c	2010-05-18 11:50:31 UTC (rev 299448)
@@ -345,25 +345,7 @@
    Fetch a result row as an associative array, a numeric array, or both */
 PHP_FUNCTION(mysqli_fetch_array)
 {
-#if !defined(MYSQLI_USE_MYSQLND)
 	php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0, 0);
-#else
-	MYSQL_RES		*result;
-	zval			*mysql_result;
-	long			mode = MYSQLND_FETCH_BOTH;
-
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l", &mysql_result, mysqli_result_class_entry, &mode) == FAILURE) {
-		return;
-	}
-	MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
-
-	if (mode < MYSQLI_ASSOC || mode > MYSQLI_BOTH) {
-		php_error_docref(NULL TSRMLS_CC, E_WARNING, "The result type should be either MYSQLI_NUM, MYSQLI_ASSOC or MYSQLI_BOTH");
-		RETURN_FALSE;
-	}
-
-	mysqlnd_fetch_into(result, mode, return_value, MYSQLND_MYSQLI);
-#endif
 }
 /* }}} */

@@ -371,19 +353,7 @@
    Fetch a result row as an associative array */
 PHP_FUNCTION(mysqli_fetch_assoc)
 {
-#if !defined(MYSQLI_USE_MYSQLND)
 	php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQLI_ASSOC, 0);
-#else
-	MYSQL_RES		*result;
-	zval			*mysql_result;
-
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) {
-		return;
-	}
-	MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
-	mysqlnd_fetch_into(result, MYSQLND_FETCH_ASSOC, return_value, MYSQLND_MYSQLI);
-
-#endif
 }
 /* }}} */

@@ -461,7 +431,6 @@
 PHP_FUNCTION(mysqli_fetch_object)
 {
 	php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQLI_ASSOC, 1);
-/* todo: mysqlnd support */
 }
 /* }}} */


Modified: php/php-src/trunk/ext/mysql/php_mysql.c
===================================================================
--- php/php-src/trunk/ext/mysql/php_mysql.c	2010-05-18 11:36:54 UTC (rev 299447)
+++ php/php-src/trunk/ext/mysql/php_mysql.c	2010-05-18 11:50:31 UTC (rev 299448)
@@ -1993,7 +1993,7 @@
 		}
 	}
 #else
-	mysqlnd_fetch_into(mysql_result, MYSQLND_FETCH_ASSOC, return_value, MYSQLND_MYSQL);
+	mysqlnd_fetch_into(mysql_result, ((result_type & MYSQL_NUM)? MYSQLND_FETCH_NUM:0) | ((result_type & MYSQL_ASSOC)? MYSQLND_FETCH_ASSOC:0), return_value, MYSQLND_MYSQL);
 #endif

 #ifdef ZEND_ENGINE_2
@@ -2071,7 +2071,7 @@
    Gets a result row as an enumerated array */
 PHP_FUNCTION(mysql_fetch_row)
 {
-#ifdef MYSQL_USE_MYSQLND
+#if 1
 	MYSQL_RES		*result;
 	zval			*mysql_result;

@@ -2105,7 +2105,7 @@
    Fetch a result row as an array (associative, numeric or both) */
 PHP_FUNCTION(mysql_fetch_array)
 {
-#ifndef MYSQL_USE_MYSQLND
+#if 1
 	php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0, 2, 0);
 #else
 	MYSQL_RES		*result;
@@ -2132,7 +2132,7 @@
    Fetch a result row as an associative array */
 PHP_FUNCTION(mysql_fetch_assoc)
 {
-#ifndef MYSQL_USE_MYSQLND
+#if 1
 	php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQL_ASSOC, 1, 0);
 #else
 	MYSQL_RES		*result;

Modified: php/php-src/trunk/ext/mysqli/mysqli_api.c
===================================================================
--- php/php-src/trunk/ext/mysqli/mysqli_api.c	2010-05-18 11:36:54 UTC (rev 299447)
+++ php/php-src/trunk/ext/mysqli/mysqli_api.c	2010-05-18 11:50:31 UTC (rev 299448)
@@ -1148,18 +1148,7 @@
    Get a result row as an enumerated array */
 PHP_FUNCTION(mysqli_fetch_row)
 {
-#if !defined(MYSQLI_USE_MYSQLND)
 	php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQLI_NUM, 0);
-#else
-	MYSQL_RES	*result;
-	zval		*mysql_result;
-
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) {
-		return;
-	}
-	MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
-	mysqlnd_fetch_into(result, MYSQLND_FETCH_NUM, return_value, MYSQLND_MYSQLI);
-#endif
 }
 /* }}} */


Modified: php/php-src/trunk/ext/mysqli/mysqli_nonapi.c
===================================================================
--- php/php-src/trunk/ext/mysqli/mysqli_nonapi.c	2010-05-18 11:36:54 UTC (rev 299447)
+++ php/php-src/trunk/ext/mysqli/mysqli_nonapi.c	2010-05-18 11:50:31 UTC (rev 299448)
@@ -345,25 +345,7 @@
    Fetch a result row as an associative array, a numeric array, or both */
 PHP_FUNCTION(mysqli_fetch_array)
 {
-#if !defined(MYSQLI_USE_MYSQLND)
 	php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0, 0);
-#else
-	MYSQL_RES		*result;
-	zval			*mysql_result;
-	long			mode = MYSQLND_FETCH_BOTH;
-
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l", &mysql_result, mysqli_result_class_entry, &mode) == FAILURE) {
-		return;
-	}
-	MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
-
-	if (mode < MYSQLI_ASSOC || mode > MYSQLI_BOTH) {
-		php_error_docref(NULL TSRMLS_CC, E_WARNING, "The result type should be either MYSQLI_NUM, MYSQLI_ASSOC or MYSQLI_BOTH");
-		RETURN_FALSE;
-	}
-
-	mysqlnd_fetch_into(result, mode, return_value, MYSQLND_MYSQLI);
-#endif
 }
 /* }}} */

@@ -371,19 +353,7 @@
    Fetch a result row as an associative array */
 PHP_FUNCTION(mysqli_fetch_assoc)
 {
-#if !defined(MYSQLI_USE_MYSQLND)
 	php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQLI_ASSOC, 0);
-#else
-	MYSQL_RES		*result;
-	zval			*mysql_result;
-
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) {
-		return;
-	}
-	MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, &mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
-	mysqlnd_fetch_into(result, MYSQLND_FETCH_ASSOC, return_value, MYSQLND_MYSQLI);
-
-#endif
 }
 /* }}} */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to