1--TEST--
2PDO_Firebird: Bug #76488 PDO Firebird does not support boolean datatype in input parameters
3--EXTENSIONS--
4pdo_firebird
5--SKIPIF--
6<?php require('skipif.inc'); ?>
7--ENV--
8LSAN_OPTIONS=detect_leaks=0
9--FILE--
10<?php
11
12require 'testdb.inc';
13
14$sql = <<<SQL
15with t(b, s) as (
16  select true, 'true' from rdb\$database
17  union all
18  select false, 'false' from rdb\$database
19  union all
20  select unknown, 'unknown' from rdb\$database
21)
22select trim(s) as s from t where b is not distinct from :p
23SQL;
24
25try {
26  $query = $dbh->prepare($sql);
27
28  // PDO::PARAM_BOOL
29  $query->bindValue('p', 0, PDO::PARAM_BOOL);
30  $query->execute();
31  var_dump($query->fetchColumn(0));
32
33  $query->bindValue('p', 1, PDO::PARAM_BOOL);
34  $query->execute();
35  var_dump($query->fetchColumn(0));
36
37  $query->bindValue('p', false, PDO::PARAM_BOOL);
38  $query->execute();
39  var_dump($query->fetchColumn(0));
40
41  $query->bindValue('p', true, PDO::PARAM_BOOL);
42  $query->execute();
43  var_dump($query->fetchColumn(0));
44
45  $query->bindValue('p', 'false', PDO::PARAM_BOOL);
46  $query->execute();
47  var_dump($query->fetchColumn(0));
48
49  $query->bindValue('p', 'True', PDO::PARAM_BOOL);
50  $query->execute();
51  var_dump($query->fetchColumn(0));
52
53  $query->bindValue('p', null, PDO::PARAM_BOOL);
54  $query->execute();
55  var_dump($query->fetchColumn(0));
56
57  // PDO::PARAM_STR
58  $query->bindValue('p', false, PDO::PARAM_STR);
59  $query->execute();
60  var_dump($query->fetchColumn(0));
61
62  $query->bindValue('p', true, PDO::PARAM_STR);
63  $query->execute();
64  var_dump($query->fetchColumn(0));
65
66  $query->bindValue('p', 0, PDO::PARAM_STR);
67  $query->execute();
68  var_dump($query->fetchColumn(0));
69
70  $query->bindValue('p', 1, PDO::PARAM_STR);
71  $query->execute();
72  var_dump($query->fetchColumn(0));
73
74  $query->bindValue('p', 'false', PDO::PARAM_STR);
75  $query->execute();
76  var_dump($query->fetchColumn(0));
77
78  $query->bindValue('p', 'true', PDO::PARAM_STR);
79  $query->execute();
80  var_dump($query->fetchColumn(0));
81
82  $query->bindValue('p', null, PDO::PARAM_STR);
83  $query->execute();
84  var_dump($query->fetchColumn(0));
85
86  // PDO::PARAM_INT
87  $query->bindValue('p', false, PDO::PARAM_INT);
88  $query->execute();
89  var_dump($query->fetchColumn(0));
90
91  $query->bindValue('p', true, PDO::PARAM_INT);
92  $query->execute();
93  var_dump($query->fetchColumn(0));
94
95  $query->bindValue('p', 0, PDO::PARAM_INT);
96  $query->execute();
97  var_dump($query->fetchColumn(0));
98
99  $query->bindValue('p', 1, PDO::PARAM_INT);
100  $query->execute();
101  var_dump($query->fetchColumn(0));
102
103  $query->bindValue('p', 'false', PDO::PARAM_INT);
104  $query->execute();
105  var_dump($query->fetchColumn(0));
106
107  $query->bindValue('p', 'true', PDO::PARAM_INT);
108  $query->execute();
109  var_dump($query->fetchColumn(0));
110
111  echo "OK\n";
112}
113catch(Exception $e) {
114    echo $e->getMessage() . '<br>';
115    echo $e->getTraceAsString();
116}
117?>
118--EXPECT--
119string(5) "false"
120string(4) "true"
121string(5) "false"
122string(4) "true"
123string(5) "false"
124string(4) "true"
125string(7) "unknown"
126string(5) "false"
127string(4) "true"
128string(5) "false"
129string(4) "true"
130string(5) "false"
131string(4) "true"
132string(7) "unknown"
133string(5) "false"
134string(4) "true"
135string(5) "false"
136string(4) "true"
137string(5) "false"
138string(4) "true"
139OK
140