bug70628.phpt 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. --TEST--
  2. Bug #70628 (Clearing bindings on an SQLite3 statement doesn't work)
  3. --EXTENSIONS--
  4. sqlite3
  5. --FILE--
  6. <?php
  7. $db = new SQLite3(':memory:');
  8. $db->exec("CREATE TABLE Dogs (Id INTEGER PRIMARY KEY, Breed TEXT, Name TEXT, Age INTEGER)");
  9. $sth = $db->prepare("INSERT INTO Dogs (Breed, Name, Age) VALUES (:breed,:name,:age)");
  10. $sth->bindValue(':breed', 'canis', SQLITE3_TEXT);
  11. $sth->bindValue(':name', 'jack', SQLITE3_TEXT);
  12. $sth->bindValue(':age', 7, SQLITE3_INTEGER);
  13. $sth->execute();
  14. $sth->clear();
  15. $sth->reset();
  16. $sth->bindValue(':breed', 'russel', SQLITE3_TEXT);
  17. $sth->bindValue(':age', 3, SQLITE3_INTEGER);
  18. $sth->execute();
  19. $res = $db->query('SELECT * FROM Dogs');
  20. while (($row = $res->fetchArray(SQLITE3_ASSOC))) {
  21. var_dump($row);
  22. }
  23. $res->finalize();
  24. $sth->close();
  25. $db->close();
  26. ?>
  27. --EXPECT--
  28. array(4) {
  29. ["Id"]=>
  30. int(1)
  31. ["Breed"]=>
  32. string(5) "canis"
  33. ["Name"]=>
  34. string(4) "jack"
  35. ["Age"]=>
  36. int(7)
  37. }
  38. array(4) {
  39. ["Id"]=>
  40. int(2)
  41. ["Breed"]=>
  42. string(6) "russel"
  43. ["Name"]=>
  44. NULL
  45. ["Age"]=>
  46. int(3)
  47. }