- dba_[p]open accepts now a new parameter, which kind of database to create

(DBA_BTREE or DBA_HASH), if the handler is either 'db2' or 'db3' and
  mode 'c' or 'n'. It is ignored if mode is 'c' and the db already exists.
# Asked on the list 4 1/2 hours ago if anyone's got to say something to this,
# no response, so I'm assuming it's ok. And yes, I did test this.
This commit is contained in:
Jouni Ahto 2000-06-27 21:36:26 +00:00
parent c860633741
commit 1dfe76f5f6
5 changed files with 43 additions and 0 deletions

4
NEWS
View File

@ -2,6 +2,10 @@ PHP 4.0 NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
28 Jun 2000, Version 4.0.1
- Added a new (fifth) parameter to dba_[p]open(), which kind of database to
create (DBA_BTREE or DBA_HASH), if the handler is either 'db2' or 'db3' and
mode 'c' or 'n'. It is ignored if mode is 'c' and the db already exists.
(Jouni)
- Fixed a bug in opendir(), which prevented readdir() from working properly if
the $dir argument wasn't explicitly specified (Zeev)
- Made --enable-discard-path work again. (Andi)

View File

@ -191,6 +191,9 @@ static PHP_MINIT_FUNCTION(dba)
zend_hash_init(&ht_keys, 0, NULL, NULL, 1);
GLOBAL(le_db) = register_list_destructors(dba_close, NULL);
GLOBAL(le_pdb) = register_list_destructors(NULL, dba_close);
REGISTER_LONG_CONSTANT("DBA_BTREE", DBA_BTREE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("DBA_HASH", DBA_HASH, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("DBA_RECNO", DBA_RECNO, CONST_CS | CONST_PERSISTENT);
return SUCCESS;
}

View File

@ -76,6 +76,21 @@ DBA_OPEN_FUNC(db2)
filemode = (*info->argv[0])->value.lval;
}
if(info->argc > 1
&& ((info->mode == DBA_CREAT && type != DB_UNKNOWN)
|| info->mode == DBA_TRUNC)) {
convert_to_long_ex(info->argv[1]);
switch ((*info->argv[1])->value.lval) {
case DBA_HASH:
type = DB_HASH;
break;
case DBA_BTREE:
default:
type = DB_BTREE;
break;
}
}
if(!db_open(info->path, type, gmode, filemode, NULL, NULL, &dbp)) {
info->dbf = malloc(sizeof(dba_db2_data));
memset(info->dbf, 0, sizeof(dba_db2_data));

View File

@ -76,6 +76,21 @@ DBA_OPEN_FUNC(db3)
filemode = (*info->argv[0])->value.lval;
}
if(info->argc > 1
&& ((info->mode == DBA_CREAT && type != DB_UNKNOWN)
|| info->mode == DBA_TRUNC)) {
convert_to_long_ex(info->argv[1]);
switch ((*info->argv[1])->value.lval) {
case DBA_HASH:
type = DB_HASH;
break;
case DBA_BTREE:
default:
type = DB_BTREE;
break;
}
}
if (db_create(&dbp, NULL, 0) == 0 &&
dbp->open(dbp, info->path, NULL, type, gmode, filemode) == 0) {
dba_db3_data *data;

View File

@ -41,6 +41,12 @@ typedef enum {
DBA_CREAT
} dba_mode_t;
typedef enum {
DBA_BTREE = 1,
DBA_HASH,
DBA_RECNO
} dba_type_t;
typedef struct dba_info {
/* public */
void *dbf; /* ptr to private data or whatever */