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