mirror of
https://github.com/php/php-src.git
synced 2025-01-27 14:13:41 +08:00
Remove duplicated code.
Use one centralized functions for data extraction.
This commit is contained in:
parent
8a402bf368
commit
c91c86b743
@ -1993,7 +1993,7 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type,
|
||||
}
|
||||
}
|
||||
#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 @@ static void php_mysql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type,
|
||||
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 @@ PHP_FUNCTION(mysql_fetch_object)
|
||||
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 @@ PHP_FUNCTION(mysql_fetch_array)
|
||||
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
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -1195,7 +1195,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
|
||||
}
|
||||
}
|
||||
#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) {
|
||||
|
@ -1148,18 +1148,7 @@ PHP_FUNCTION(mysqli_fetch_lengths)
|
||||
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
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -345,25 +345,7 @@ PHP_FUNCTION(mysqli_connect_error)
|
||||
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 @@ PHP_FUNCTION(mysqli_fetch_array)
|
||||
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_get_connection_stats)
|
||||
PHP_FUNCTION(mysqli_fetch_object)
|
||||
{
|
||||
php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQLI_ASSOC, 1);
|
||||
/* todo: mysqlnd support */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user