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