Skip to content

Commit 78f23a6

Browse files
madorinweltling
authored andcommitted
Boolean data type support, added in Firebird 3. Fixes #74462.
1 parent e51b364 commit 78f23a6

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

ext/pdo_firebird/firebird_statement.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
+----------------------------------------------------------------------+
33
| PHP Version 7 |
44
+----------------------------------------------------------------------+
@@ -229,6 +229,9 @@ static int firebird_stmt_describe(pdo_stmt_t *stmt, int colno) /* {{{ */
229229
#endif
230230
col->param_type = PDO_PARAM_INT;
231231
break;
232+
case SQL_BOOLEAN:
233+
col->param_type = PDO_PARAM_BOOL;
234+
break;
232235
default:
233236
col->param_type = PDO_PARAM_STR;
234237
break;
@@ -416,6 +419,11 @@ static int firebird_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, /* {{
416419
*ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL);
417420
*len = slprintf(*ptr, CHAR_BUF_LEN, "%F" , *(double*)var->sqldata);
418421
break;
422+
case SQL_BOOLEAN:
423+
*len = sizeof(zend_bool);
424+
*ptr = FETCH_BUF(S->fetch_buf[colno], zend_bool, 1, NULL);
425+
*(zend_bool*)*ptr = *(FB_BOOLEAN*)var->sqldata;
426+
break;
419427
case SQL_TYPE_DATE:
420428
isc_decode_sql_date((ISC_DATE*)var->sqldata, &t);
421429
fmt = S->H->date_format ? S->H->date_format : PDO_FB_DEF_DATE_FMT;

ext/pdo_firebird/tests/bug_74462.phpt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
PDO_Firebird: Bug #74462 Returns only NULLs for boolean fields
3+
--SKIPIF--
4+
<?php if (!extension_loaded('interbase') || !extension_loaded('pdo_firebird')) die('skip');
5+
?>
6+
--FILE--
7+
<?php
8+
require 'testdb.inc';
9+
$C = new PDO('firebird:dbname='.$test_base, $user, $password) or die;
10+
@$C->exec('drop table atable');
11+
$C->exec('create table atable (id integer not null, abool boolean)');
12+
$C->exec('insert into atable (id, abool) values (1, true)');
13+
$C->exec('insert into atable (id, abool) values (2, false)');
14+
$C->exec('insert into atable (id, abool) values (3, null)');
15+
$S = $C->query('select abool from atable order by id');
16+
$D = $S->fetchAll(PDO::FETCH_COLUMN);
17+
unset($S);
18+
unset($C);
19+
var_dump($D);
20+
?>
21+
--EXPECT--
22+
array(3) {
23+
[0]=>
24+
bool(true)
25+
[1]=>
26+
bool(false)
27+
[2]=>
28+
NULL
29+
}

0 commit comments

Comments
 (0)