You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.3 KiB

23 years ago
23 years ago
23 years ago
  1. --TEST--
  2. sqlite-oo: fetch column
  3. --INI--
  4. sqlite.assoc_case=0
  5. --SKIPIF--
  6. <?php # vim:ft=php
  7. if (!extension_loaded("sqlite")) print "skip"; ?>
  8. --FILE--
  9. <?php
  10. include "blankdb_oo.inc";
  11. $data = array(
  12. array (0 => 'one', 1 => 'two'),
  13. array (0 => 'three', 1 => 'four')
  14. );
  15. $db->query("CREATE TABLE strings(a VARCHAR, b VARCHAR)");
  16. foreach ($data as $str) {
  17. $db->query("INSERT INTO strings VALUES('${str[0]}','${str[1]}')");
  18. }
  19. echo "====BUFFERED====\n";
  20. $r = $db->query("SELECT a, b from strings");
  21. while ($r->valid()) {
  22. var_dump($r->current(SQLITE_NUM));
  23. var_dump($r->column(0));
  24. var_dump($r->column(1));
  25. var_dump($r->column('a'));
  26. var_dump($r->column('b'));
  27. $r->next();
  28. }
  29. echo "====UNBUFFERED====\n";
  30. $r = $db->unbufferedQuery("SELECT a, b from strings");
  31. while ($r->valid()) {
  32. var_dump($r->column(0));
  33. var_dump($r->column('b'));
  34. var_dump($r->column(1));
  35. var_dump($r->column('a'));
  36. $r->next();
  37. }
  38. echo "DONE!\n";
  39. ?>
  40. --EXPECT--
  41. ====BUFFERED====
  42. array(2) {
  43. [0]=>
  44. string(3) "one"
  45. [1]=>
  46. string(3) "two"
  47. }
  48. string(3) "one"
  49. string(3) "two"
  50. string(3) "one"
  51. string(3) "two"
  52. array(2) {
  53. [0]=>
  54. string(5) "three"
  55. [1]=>
  56. string(4) "four"
  57. }
  58. string(5) "three"
  59. string(4) "four"
  60. string(5) "three"
  61. string(4) "four"
  62. ====UNBUFFERED====
  63. string(3) "one"
  64. string(3) "two"
  65. NULL
  66. NULL
  67. string(5) "three"
  68. string(4) "four"
  69. NULL
  70. NULL
  71. DONE!