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