bug70628.phpt 1.1 KB

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