Return array of available PDO drivers */
PHP_FUNCTION(pdo_drivers)
{
- HashPosition pos;
pdo_driver_t *pdriver;
if (zend_parse_parameters_none() == FAILURE) {
array_init(return_value);
- zend_hash_internal_pointer_reset_ex(&pdo_driver_hash, &pos);
- while ((pdriver = zend_hash_get_current_data_ptr_ex(&pdo_driver_hash, &pos)) != NULL) {
+ ZEND_HASH_FOREACH_PTR(&pdo_driver_hash, pdriver) {
add_next_index_stringl(return_value, (char*)pdriver->driver_name, pdriver->driver_name_len);
- zend_hash_move_forward_ex(&pdo_driver_hash, &pos);
- }
+ } ZEND_HASH_FOREACH_END();
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION */
PHP_MINFO_FUNCTION(pdo)
{
- HashPosition pos;
char *drivers = NULL, *ldrivers = estrdup("");
pdo_driver_t *pdriver;
php_info_print_table_start();
php_info_print_table_header(2, "PDO support", "enabled");
- zend_hash_internal_pointer_reset_ex(&pdo_driver_hash, &pos);
- while ((pdriver = zend_hash_get_current_data_ptr_ex(&pdo_driver_hash, &pos))) {
+ ZEND_HASH_FOREACH_PTR(&pdo_driver_hash, pdriver) {
spprintf(&drivers, 0, "%s, %s", ldrivers, pdriver->driver_name);
- zend_hash_move_forward_ex(&pdo_driver_hash, &pos);
efree(ldrivers);
ldrivers = drivers;
- }
+ } ZEND_HASH_FOREACH_END();
php_info_print_table_row(2, "PDO drivers", drivers ? drivers + 2 : "");
options:
if (options) {
zval *attr_value;
- zend_string *str_key;
ulong long_key;
+ zend_string *str_key = NULL;
- zend_hash_internal_pointer_reset(Z_ARRVAL_P(options));
- while ((attr_value = zend_hash_get_current_data(Z_ARRVAL_P(options))) != NULL
- && HASH_KEY_IS_LONG == zend_hash_get_current_key(Z_ARRVAL_P(options), &str_key, &long_key, 0)) {
-
+ ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(options), long_key, str_key, attr_value) {
+ if (str_key) {
+ continue;
+ }
pdo_dbh_attribute_set(dbh, long_key, attr_value TSRMLS_CC);
- zend_hash_move_forward(Z_ARRVAL_P(options));
- }
+ } ZEND_HASH_FOREACH_END();
}
return;
Return array of available PDO drivers */
static PHP_METHOD(PDO, getAvailableDrivers)
{
- HashPosition pos;
pdo_driver_t *pdriver;
if (zend_parse_parameters_none() == FAILURE) {
array_init(return_value);
- zend_hash_internal_pointer_reset_ex(&pdo_driver_hash, &pos);
- while ((pdriver = zend_hash_get_current_data_ptr_ex(&pdo_driver_hash, &pos)) != NULL) {
+ ZEND_HASH_FOREACH_PTR(&pdo_driver_hash, pdriver) {
add_next_index_stringl(return_value, (char*)pdriver->driver_name, pdriver->driver_name_len);
- zend_hash_move_forward_ex(&pdo_driver_hash, &pos);
- }
+ } ZEND_HASH_FOREACH_END();
}
/* }}} */