diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/dba/tests/dba_cdb_read.phpt | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/dba/tests/dba_cdb_read.phpt')
-rw-r--r-- | ext/dba/tests/dba_cdb_read.phpt | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/ext/dba/tests/dba_cdb_read.phpt b/ext/dba/tests/dba_cdb_read.phpt new file mode 100644 index 0000000..71575f5 --- /dev/null +++ b/ext/dba/tests/dba_cdb_read.phpt @@ -0,0 +1,65 @@ +--TEST-- +DBA CDB handler test (read only) +--SKIPIF-- +<?php + $handler = 'cdb_make'; + require_once dirname(__FILE__) .'/skipif.inc'; +?> +--FILE-- +<?php + echo "database handler: cdb\n"; + $handler = 'cdb'; + $db_file = dirname(__FILE__).'/test.cdb'; + if (($db_file=dba_open($db_file, "r", $handler))!==FALSE) { + // read key sequence + $a = dba_firstkey($db_file); + $count= 0; + $keys = $a; + while($a) { + $a = dba_nextkey($db_file); + $keys .= $a; + $count++; + } + // display number of entries and key existance + echo $count; + for ($i=1; $i<8; $i++) { + echo dba_exists($i, $db_file) ? "Y" : "N"; + } + echo "\n="; + echo dba_fetch(1, $db_file); + echo dba_fetch(2, $db_file); + echo dba_fetch(3, $db_file); + echo dba_fetch(4, $db_file); + echo "\n#"; + echo dba_fetch(1, $db_file); + echo dba_fetch(1, $db_file); + echo dba_fetch(2, $db_file); + echo dba_fetch(2, $db_file); + echo "\n?".$keys; + // with skip = 0 dba_fetch must fetch the first result + echo "\n#"; + $skip = array(); + for ($i=0; $i < strlen($keys); $i++) { + $key = substr($keys, $i, 1); + $skip[$key] = 0; + echo dba_fetch($key, $db_file); + } + echo "\n="; + for ($i=0; $i < strlen($keys); $i++) { + $key = substr($keys, $i, 1); + echo dba_fetch($key, $skip[$key], $db_file); + $skip[$key]++; + } + dba_close($db_file); + } else { + echo "Error creating database\n"; + } +?> +--EXPECT-- +database handler: cdb +7YYYYNNN +=1234 +#1122 +?1212314 +#1212314 +=1231324 |