Browse Source

Boolean data type support, added in Firebird 3. Fixes #74462.

pull/3362/merge
Dorin Marcoci 9 years ago
committed by Anatol Belski
parent
commit
78f23a6dd4
  1. 10
      ext/pdo_firebird/firebird_statement.c
  2. 29
      ext/pdo_firebird/tests/bug_74462.phpt

10
ext/pdo_firebird/firebird_statement.c

@ -1,4 +1,4 @@
/*
/*
+----------------------------------------------------------------------+ +----------------------------------------------------------------------+
| PHP Version 7 | | PHP Version 7 |
+----------------------------------------------------------------------+ +----------------------------------------------------------------------+
@ -229,6 +229,9 @@ static int firebird_stmt_describe(pdo_stmt_t *stmt, int colno) /* {{{ */
#endif #endif
col->param_type = PDO_PARAM_INT; col->param_type = PDO_PARAM_INT;
break; break;
case SQL_BOOLEAN:
col->param_type = PDO_PARAM_BOOL;
break;
default: default:
col->param_type = PDO_PARAM_STR; col->param_type = PDO_PARAM_STR;
break; break;
@ -416,6 +419,11 @@ static int firebird_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, /* {{
*ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL); *ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL);
*len = slprintf(*ptr, CHAR_BUF_LEN, "%F" , *(double*)var->sqldata); *len = slprintf(*ptr, CHAR_BUF_LEN, "%F" , *(double*)var->sqldata);
break; break;
case SQL_BOOLEAN:
*len = sizeof(zend_bool);
*ptr = FETCH_BUF(S->fetch_buf[colno], zend_bool, 1, NULL);
*(zend_bool*)*ptr = *(FB_BOOLEAN*)var->sqldata;
break;
case SQL_TYPE_DATE: case SQL_TYPE_DATE:
isc_decode_sql_date((ISC_DATE*)var->sqldata, &t); isc_decode_sql_date((ISC_DATE*)var->sqldata, &t);
fmt = S->H->date_format ? S->H->date_format : PDO_FB_DEF_DATE_FMT; fmt = S->H->date_format ? S->H->date_format : PDO_FB_DEF_DATE_FMT;

29
ext/pdo_firebird/tests/bug_74462.phpt

@ -0,0 +1,29 @@
--TEST--
PDO_Firebird: Bug #74462 Returns only NULLs for boolean fields
--SKIPIF--
<?php if (!extension_loaded('interbase') || !extension_loaded('pdo_firebird')) die('skip');
?>
--FILE--
<?php
require 'testdb.inc';
$C = new PDO('firebird:dbname='.$test_base, $user, $password) or die;
@$C->exec('drop table atable');
$C->exec('create table atable (id integer not null, abool boolean)');
$C->exec('insert into atable (id, abool) values (1, true)');
$C->exec('insert into atable (id, abool) values (2, false)');
$C->exec('insert into atable (id, abool) values (3, null)');
$S = $C->query('select abool from atable order by id');
$D = $S->fetchAll(PDO::FETCH_COLUMN);
unset($S);
unset($C);
var_dump($D);
?>
--EXPECT--
array(3) {
[0]=>
bool(true)
[1]=>
bool(false)
[2]=>
NULL
}
Loading…
Cancel
Save