dba005.phpt 962 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. --TEST--
  2. DBA FirstKey/NextKey Loop Test With 5 Items
  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("key1", "Content String 1", $db_file);
  14. dba_insert("key2", "Content String 2", $db_file);
  15. dba_insert("key3", "Third Content String", $db_file);
  16. dba_insert("key4", "Another Content String", $db_file);
  17. dba_insert("key5", "The last content string", $db_file);
  18. $a = dba_firstkey($db_file);
  19. $i=0;
  20. while($a) {
  21. $a = dba_nextkey($db_file);
  22. $i++;
  23. }
  24. echo $i;
  25. for ($i=1; $i<6; $i++) {
  26. echo dba_exists("key$i", $db_file) ? "Y" : "N";
  27. }
  28. dba_close($db_file);
  29. } else {
  30. echo "Error creating database\n";
  31. }
  32. ?>
  33. --CLEAN--
  34. <?php
  35. require(dirname(__FILE__) .'/clean.inc');
  36. ?>
  37. --EXPECTF--
  38. database handler: %s
  39. 5YYYYY