From: Frank M. Kromann Date: Thu, 3 Jul 2003 16:47:10 +0000 (+0000) Subject: Change fetch functions and protos so they make more sense. X-Git-Tag: php-4.3.3RC2~177 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e5523b4954248084a24b8190a31a2891ca04b7b1;p=php Change fetch functions and protos so they make more sense. fetch_row or fetch_assoc should not take the optional parameter --- diff --git a/ext/fbsql/php_fbsql.c b/ext/fbsql/php_fbsql.c index d679a25264..39519a9594 100644 --- a/ext/fbsql/php_fbsql.c +++ b/ext/fbsql/php_fbsql.c @@ -358,9 +358,9 @@ static void phpfbQuery(INTERNAL_FUNCTION_PARAMETERS, char* sql, PHPFBLink* link) /* {{{ PHP_INI */ PHP_INI_BEGIN() - STD_PHP_INI_BOOLEAN ("fbsql.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateInt, allowPersistent, zend_fbsql_globals, fbsql_globals) - STD_PHP_INI_BOOLEAN ("fbsql.generate_warnings", "0", PHP_INI_SYSTEM, OnUpdateInt, generateWarnings, zend_fbsql_globals, fbsql_globals) - STD_PHP_INI_BOOLEAN ("fbsql.autocommit", "1", PHP_INI_SYSTEM, OnUpdateInt, autoCommit, zend_fbsql_globals, fbsql_globals) + STD_PHP_INI_BOOLEAN ("fbsql.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateBool, allowPersistent, zend_fbsql_globals, fbsql_globals) + STD_PHP_INI_BOOLEAN ("fbsql.generate_warnings", "0", PHP_INI_SYSTEM, OnUpdateBool, generateWarnings, zend_fbsql_globals, fbsql_globals) + STD_PHP_INI_BOOLEAN ("fbsql.autocommit", "1", PHP_INI_SYSTEM, OnUpdateBool, autoCommit, zend_fbsql_globals, fbsql_globals) STD_PHP_INI_ENTRY_EX ("fbsql.max_persistent", "-1", PHP_INI_SYSTEM, OnUpdateInt, maxPersistent, zend_fbsql_globals, fbsql_globals, display_link_numbers) STD_PHP_INI_ENTRY_EX ("fbsql.max_links", "128", PHP_INI_SYSTEM, OnUpdateInt, maxLinks, zend_fbsql_globals, fbsql_globals, display_link_numbers) STD_PHP_INI_ENTRY_EX ("fbsql.max_connections", "128", PHP_INI_SYSTEM, OnUpdateInt, maxConnections, zend_fbsql_globals, fbsql_globals, display_link_numbers) @@ -2706,7 +2706,7 @@ PHP_FUNCTION(fbsql_num_fields) Fetch a row of data. Returns an indexed array */ PHP_FUNCTION(fbsql_fetch_row) { - php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, FBSQL_NUM); + php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, FBSQL_NUM, 1); } /* }}} */ @@ -2714,7 +2714,7 @@ PHP_FUNCTION(fbsql_fetch_row) Detch a row of data. Returns an assoc array */ PHP_FUNCTION(fbsql_fetch_assoc) { - php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, FBSQL_ASSOC); + php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, FBSQL_ASSOC, 1); } /* }}} */ @@ -2722,7 +2722,7 @@ PHP_FUNCTION(fbsql_fetch_assoc) Fetch a row of data. Returns an object */ PHP_FUNCTION(fbsql_fetch_object) { - php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, FBSQL_ASSOC); + php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, FBSQL_ASSOC, 2); if (Z_TYPE_P(return_value)==IS_ARRAY) { object_and_properties_init(return_value, ZEND_STANDARD_CLASS_DEF_PTR, Z_ARRVAL_P(return_value)); } @@ -2733,7 +2733,7 @@ PHP_FUNCTION(fbsql_fetch_object) Fetches a result row as an array (associative, numeric or both)*/ PHP_FUNCTION(fbsql_fetch_array) { - php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, FBSQL_BOTH); + php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, FBSQL_BOTH, 2); } /* }}} */ @@ -2781,7 +2781,7 @@ static void _parse_list(zval** return_value, FBCPList* list) } } -static void php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type) +static void php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type, int expected_args) { PHPFBResult* result = NULL; @@ -2790,6 +2790,10 @@ static void php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type) int i; void **row; + if (ZEND_NUM_ARGS() > expected_args) { + WRONG_PARAM_COUNT; + } + switch (ZEND_NUM_ARGS()) { case 1: if (zend_get_parameters_ex(1, &fbsql_result_index)==FAILURE) { diff --git a/ext/fbsql/php_fbsql.h b/ext/fbsql/php_fbsql.h index 592f45c5c7..1ded8eaaad 100644 --- a/ext/fbsql/php_fbsql.h +++ b/ext/fbsql/php_fbsql.h @@ -101,7 +101,7 @@ PHP_FUNCTION(fbsql_warnings); PHP_FUNCTION(fbsql_get_autostart_info); /* PHP_FUNCTION(fbsql_set_autostart_info); */ -static void php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type); +static void php_fbsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type, int expected_args); static void php_fbsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent); ZEND_BEGIN_MODULE_GLOBALS(fbsql) diff --git a/ext/mssql/php_mssql.c b/ext/mssql/php_mssql.c index 21612aab30..6a85dd2214 100644 --- a/ext/mssql/php_mssql.c +++ b/ext/mssql/php_mssql.c @@ -1262,12 +1262,16 @@ PHP_FUNCTION(mssql_num_fields) /* }}} */ -static void php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type) +static void php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type, int expected_args) { zval **mssql_result_index, **resulttype = NULL; mssql_result *result; int i; + if (ZEND_NUM_ARGS() > expected_args) { + WRONG_PARAM_COUNT; + } + switch (ZEND_NUM_ARGS()) { case 1: if (zend_get_parameters_ex(1, &mssql_result_index)==FAILURE) { @@ -1357,11 +1361,11 @@ static void php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type) result->cur_row++; } -/* {{{ proto array mssql_fetch_row(resource result_id [, int result_type]) +/* {{{ proto array mssql_fetch_row(resource result_id) Returns an array of the current row in the result set specified by result_id */ PHP_FUNCTION(mssql_fetch_row) { - php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MSSQL_NUM); + php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MSSQL_NUM, 1); } /* }}} */ @@ -1370,7 +1374,7 @@ PHP_FUNCTION(mssql_fetch_row) Returns a psuedo-object of the current row in the result set specified by result_id */ PHP_FUNCTION(mssql_fetch_object) { - php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MSSQL_ASSOC); + php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MSSQL_ASSOC, 2); if (Z_TYPE_P(return_value)==IS_ARRAY) { object_and_properties_init(return_value, ZEND_STANDARD_CLASS_DEF_PTR, Z_ARRVAL_P(return_value)); } @@ -1382,16 +1386,16 @@ PHP_FUNCTION(mssql_fetch_object) Returns an associative array of the current row in the result set specified by result_id */ PHP_FUNCTION(mssql_fetch_array) { - php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MSSQL_BOTH); + php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MSSQL_BOTH, 2); } /* }}} */ -/* {{{ proto array mssql_fetch_assoc(resource result_id [, int result_type]) +/* {{{ proto array mssql_fetch_assoc(resource result_id) Returns an associative array of the current row in the result set specified by result_id */ PHP_FUNCTION(mssql_fetch_assoc) { - php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MSSQL_ASSOC); + php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MSSQL_ASSOC, 1); } /* }}} */