dba010.phpt 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --TEST--
  2. DBA with array keys
  3. --EXTENSIONS--
  4. dba
  5. --SKIPIF--
  6. <?php
  7. require_once(__DIR__ .'/skipif.inc');
  8. die("info $HND handler used");
  9. ?>
  10. --FILE--
  11. <?php
  12. require_once(__DIR__ .'/test.inc');
  13. echo "database handler: $handler\n";
  14. if (($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. --CLEAN--
  40. <?php
  41. require(__DIR__ .'/clean.inc');
  42. ?>
  43. --EXPECTF--
  44. database handler: %s
  45. 6YYYYYY