1--TEST--
2Bug #68849 bindValue is not using the right data type
3--SKIPIF--
4<?php require_once(__DIR__ . '/skipif.inc'); ?>
5--FILE--
6<?php
7
8$db = new SQLite3(':memory:');
9
10$db->exec("CREATE TABLE test (a INTEGER, b TEXT, c REAL);" .
11        "INSERT INTO test VALUES (1, 'hello', 3.14);" .
12        "INSERT INTO test VALUES (3, 'world', 3.15);" .
13        "INSERT INTO test VALUES (0, '42', 0.42);"
14);
15
16$s = $db->prepare('SELECT * FROM test WHERE (a+2) = ?;');
17$s->bindValue(1, 3);
18$r = $s->execute();
19var_dump($r->fetchArray(SQLITE3_ASSOC));
20
21$s = $db->prepare('SELECT * FROM test WHERE a = ?;');
22$s->bindValue(1, true);
23$r = $s->execute();
24var_dump($r->fetchArray(SQLITE3_ASSOC));
25
26$s = $db->prepare('SELECT * FROM test WHERE a = ?;');
27$s->bindValue(1, false);
28$r = $s->execute();
29var_dump($r->fetchArray(SQLITE3_ASSOC));
30
31$s = $db->prepare('SELECT * FROM test WHERE c = ?;');
32$s->bindValue(1, 3.15);
33$r = $s->execute();
34var_dump($r->fetchArray(SQLITE3_ASSOC));
35
36?>
37--EXPECT--
38array(3) {
39  ["a"]=>
40  int(1)
41  ["b"]=>
42  string(5) "hello"
43  ["c"]=>
44  float(3.14)
45}
46array(3) {
47  ["a"]=>
48  int(1)
49  ["b"]=>
50  string(5) "hello"
51  ["c"]=>
52  float(3.14)
53}
54array(3) {
55  ["a"]=>
56  int(0)
57  ["b"]=>
58  string(2) "42"
59  ["c"]=>
60  float(0.42)
61}
62array(3) {
63  ["a"]=>
64  int(3)
65  ["b"]=>
66  string(5) "world"
67  ["c"]=>
68  float(3.15)
69}
70