PHP_FE(dba_optimize, NULL)
PHP_FE(dba_sync, NULL)
PHP_FE(dba_handlers, NULL)
+ PHP_FE(dba_list, NULL)
{NULL, NULL, NULL}
};
/* }}} */
}
/* }}} */
-/* {{{ proto array dba_list()
+/* {{{ proto array dba_handlers()
List configured databases */
PHP_FUNCTION(dba_handlers)
{
}
/* }}} */
+/* {{{ proto array dba_list()
+ List configured databases */
+PHP_FUNCTION(dba_list)
+{
+ ulong numitems, i;
+ zend_rsrc_list_entry *le;
+ dba_info *info;
+
+ if (ZEND_NUM_ARGS()!=0) {
+ ZEND_WRONG_PARAM_COUNT();
+ RETURN_FALSE;
+ }
+
+ if (array_init(return_value) == FAILURE) {
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to initialize array");
+ RETURN_FALSE;
+ }
+ numitems = zend_hash_next_free_element(&EG(regular_list));
+ for (i=1; i<numitems; i++) {
+ if (zend_hash_index_find(&EG(regular_list), i, (void **) &le)==FAILURE) {
+ continue;
+ }
+ if (Z_TYPE_P(le) == le_db || Z_TYPE_P(le) == le_pdb) {
+ info = (dba_info *)(le->ptr);
+ add_index_string(return_value, i, info->path, 1);
+ }
+ }
+}
+/* }}} */
+
#endif
/*
PHP_FUNCTION(dba_optimize);
PHP_FUNCTION(dba_sync);
PHP_FUNCTION(dba_handlers);
+PHP_FUNCTION(dba_list);
#else
#define dba_module_ptr NULL
--- /dev/null
+--TEST--
+DBA Multiple File Creation Test
+--SKIPIF--
+<?php
+ require_once('skipif.inc');
+ if (!function_exists('dba_list')) die('skip dba_list() not available');
+?>
+--FILE--
+<?php
+ require_once('test.inc');
+ $db_file1 = dirname(__FILE__).'/test1.dbm';
+ $db_file2 = dirname(__FILE__).'/test2.dbm';
+ if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
+ echo "database file created with $handler.\n";
+ } else {
+ echo "$db_file does not exist\n";
+ }
+ if (($db_file1=dba_open($db_file1, "n", $handler))!==FALSE) {
+ echo "database file created with $handler.\n";
+ } else {
+ echo "$db_file does not exist\n";
+ }
+ if (($db_file2=dba_open($db_file2, "n", $handler))!==FALSE) {
+ echo "database file created with $handler.\n";
+ } else {
+ echo "$db_file does not exist\n";
+ }
+ var_dump(dba_list());
+ dba_close($db_file);
+?>
+--EXPECTF--
+database file created with %s.
+array(3) {
+ [%d]=>
+ string(%d) "%sext/dba/tests/test.dbm"
+ [%d]=>
+ string(%d) "%sext/dba/tests/test1.dbm"
+ [%d]=>
+ string(%d) "%sext/dba/tests/test2.dbm"
+}
\ No newline at end of file