Skip to content

Commit a6ecafe

Browse files
committed
Use external iterator instead of via the internal pointer
1 parent a0051be commit a6ecafe

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

ext/odbc/php_odbc.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ PHP_FUNCTION(odbc_execute)
977977
int i, ne;
978978
RETCODE rc;
979979

980-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|h/", &pv_res, &pv_param_ht) == FAILURE) {
980+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|h", &pv_res, &pv_param_ht) == FAILURE) {
981981
RETURN_THROWS();
982982
}
983983

@@ -991,25 +991,13 @@ PHP_FUNCTION(odbc_execute)
991991
RETURN_FALSE;
992992
}
993993

994-
zend_hash_internal_pointer_reset(pv_param_ht);
995994
params = (params_t *)safe_emalloc(sizeof(params_t), result->numparams, 0);
996995
for(i = 0; i < result->numparams; i++) {
997996
params[i].fp = -1;
998997
}
999998

1000-
for(i = 1; i <= result->numparams; i++) {
1001-
if ((tmp = zend_hash_get_current_data(pv_param_ht)) == NULL) {
1002-
php_error_docref(NULL, E_WARNING,"Error getting parameter");
1003-
SQLFreeStmt(result->stmt,SQL_RESET_PARAMS);
1004-
for (i = 0; i < result->numparams; i++) {
1005-
if (params[i].fp != -1) {
1006-
close(params[i].fp);
1007-
}
1008-
}
1009-
efree(params);
1010-
RETURN_FALSE;
1011-
}
1012-
999+
i = 1;
1000+
ZEND_HASH_FOREACH_VAL(pv_param_ht, tmp) {
10131001
otype = Z_TYPE_P(tmp);
10141002
if (!try_convert_to_string(tmp)) {
10151003
SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
@@ -1099,8 +1087,8 @@ PHP_FUNCTION(odbc_execute)
10991087
efree(params);
11001088
RETURN_FALSE;
11011089
}
1102-
zend_hash_move_forward(pv_param_ht);
1103-
}
1090+
if (i++ > result->numparams) break;
1091+
} ZEND_HASH_FOREACH_END();
11041092
}
11051093
/* Close cursor, needed for doing multiple selects */
11061094
rc = SQLFreeStmt(result->stmt, SQL_CLOSE);

0 commit comments

Comments
 (0)