xref: /PHP-8.1/ext/dba/tests/dba010.phpt (revision b5a14e6c)
1--TEST--
2DBA with array keys
3--EXTENSIONS--
4dba
5--SKIPIF--
6<?php
7    require_once(__DIR__ .'/skipif.inc');
8    die("info $HND handler used");
9?>
10--FILE--
11<?php
12require_once(__DIR__ .'/test.inc');
13echo "database handler: $handler\n";
14if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
15    dba_insert(array("", "name0") , "Content String 1", $db_file);
16    dba_insert(array("key1", "name1") , "Content String 1", $db_file);
17    dba_insert(array("key2","name2"), "Content String 2", $db_file);
18    dba_insert("[key3]name3", "Third Content String", $db_file);
19    dba_insert(array("key4","name4"), "Another Content String", $db_file);
20    dba_insert(array("key5","name5"), "The last content string", $db_file);
21    $a = dba_firstkey($db_file);
22    $i=0;
23    while($a) {
24        $a = dba_nextkey($db_file);
25        $i++;
26    }
27    echo $i;
28    echo dba_exists(array("","name0"), $db_file) ? "Y" : "N";
29    for ($i=1; $i<5; $i++) {
30        echo dba_exists("[key$i]name$i", $db_file) ? "Y" : "N";
31    }
32    echo dba_exists(array("key5","name5"), $db_file) ? "Y" : "N";
33    echo "\n";
34    dba_close($db_file);
35} else {
36    echo "Error creating database\n";
37}
38
39?>
40--CLEAN--
41<?php
42    require(__DIR__ .'/clean.inc');
43?>
44--EXPECTF--
45database handler: %s
466YYYYYY
47