dba005.phpt 1.1 KB

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