diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-09-29 11:41:17 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-09-29 11:41:17 +0200 |
commit | a6ecafece90909d74a578e09f626e875d3035eab (patch) | |
tree | 3302149f6148d5fb743c7907745f83275f0fc99a | |
parent | a0051be42a0b2f510eda551217e0e5405b15eea3 (diff) | |
download | php-git-a6ecafece90909d74a578e09f626e875d3035eab.tar.gz |
Use external iterator instead of via the internal pointer
-rw-r--r-- | ext/odbc/php_odbc.c | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index 09c71b97cf..a64501c3ef 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -977,7 +977,7 @@ PHP_FUNCTION(odbc_execute) int i, ne; RETCODE rc; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|h/", &pv_res, &pv_param_ht) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|h", &pv_res, &pv_param_ht) == FAILURE) { RETURN_THROWS(); } @@ -991,25 +991,13 @@ PHP_FUNCTION(odbc_execute) RETURN_FALSE; } - zend_hash_internal_pointer_reset(pv_param_ht); params = (params_t *)safe_emalloc(sizeof(params_t), result->numparams, 0); for(i = 0; i < result->numparams; i++) { params[i].fp = -1; } - for(i = 1; i <= result->numparams; i++) { - if ((tmp = zend_hash_get_current_data(pv_param_ht)) == NULL) { - php_error_docref(NULL, E_WARNING,"Error getting parameter"); - SQLFreeStmt(result->stmt,SQL_RESET_PARAMS); - for (i = 0; i < result->numparams; i++) { - if (params[i].fp != -1) { - close(params[i].fp); - } - } - efree(params); - RETURN_FALSE; - } - + i = 1; + ZEND_HASH_FOREACH_VAL(pv_param_ht, tmp) { otype = Z_TYPE_P(tmp); if (!try_convert_to_string(tmp)) { SQLFreeStmt(result->stmt, SQL_RESET_PARAMS); @@ -1099,8 +1087,8 @@ PHP_FUNCTION(odbc_execute) efree(params); RETURN_FALSE; } - zend_hash_move_forward(pv_param_ht); - } + if (i++ > result->numparams) break; + } ZEND_HASH_FOREACH_END(); } /* Close cursor, needed for doing multiple selects */ rc = SQLFreeStmt(result->stmt, SQL_CLOSE); |