dba010.phpt 1.2 KB

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