dba_db4_016.phpt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. --TEST--
  2. DBA DB4 File Creation popen("c") with existing valid file
  3. --SKIPIF--
  4. <?php
  5. $handler = "db4";
  6. require_once(dirname(__FILE__) .'/skipif.inc');
  7. die("info $HND handler used");
  8. ?>
  9. --FILE--
  10. <?php
  11. $handler = "db4";
  12. require_once(dirname(__FILE__) .'/test.inc');
  13. echo "database handler: $handler\n";
  14. if (($db_file = dba_popen($db_filename, "c", $handler)) !== FALSE) {
  15. if (file_exists($db_filename)) {
  16. echo "database file created\n";
  17. var_dump(dba_insert("key1", "This is a test insert", $db_file));
  18. echo dba_fetch("key1", $db_file), "\n";
  19. dba_close($db_file);
  20. } else {
  21. echo "File did not get created\n";
  22. }
  23. } else {
  24. echo "Error creating $db_filename\n";
  25. }
  26. // Now test reopening it
  27. if (($db_file = dba_popen($db_filename, "c", $handler)) !== FALSE) {
  28. if (file_exists($db_filename)) {
  29. echo "database file created\n";
  30. var_dump(dba_insert("key1", "second open test", $db_file));
  31. var_dump(dba_insert("key2", "second open test row 2", $db_file));
  32. echo dba_fetch("key1", $db_file), "\n";
  33. echo dba_fetch("key2", $db_file), "\n";
  34. dba_close($db_file);
  35. } else {
  36. echo "File did not get created\n";
  37. }
  38. } else {
  39. echo "Error creating $db_filename\n";
  40. }
  41. ?>
  42. --CLEAN--
  43. <?php
  44. require(dirname(__FILE__) .'/clean.inc');
  45. ?>
  46. --EXPECT--
  47. database handler: db4
  48. database file created
  49. bool(true)
  50. This is a test insert
  51. database file created
  52. bool(false)
  53. bool(true)
  54. This is a test insert
  55. second open test row 2