|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-02-18 22:10 UTC] josemalonsom at yahoo dot es
Description:
------------
PHP: 5.5.8
Informix IDS: 12.10.UC2DE
CSDK: 4.10.UC2DE
PDO_INFORMIX: 1.3.1
When a column of some LOB type, TEXT, BYTE, CLOB or BLOB has NULL as value an empty string is returned instead of NULL when the value is fetched, occurs also when the PDO::ATTR_STRINGIFY_FETCHES driver option is set to true.
Test script:
---------------
// $con has a valid PDO_INFORMIX connection.
$sql = 'create table t1 ( c1 char(1), c2 char(1), ctext text, cbyte byte, cclob clob, cblob blob )';
$con->exec($sql);
$sql = "insert into t1 (c1) values ('A')";
$con->exec($sql);
$row = $con->query('select * from t1')->fetch(PDO::FETCH_ASSOC);
foreach ($row as $field => &$value) {
if (is_resource($value)) {
$value = stream_get_contents($value);
}
}
var_dump($row);
Expected result:
----------------
All the LOB types must be NULL.
Actual result:
--------------
array(6) {
'C1' =>
string(1) "A"
'C2' =>
NULL
'CTEXT' =>
string(0) ""
'CBYTE' =>
string(0) ""
'CCLOB' =>
string(0) ""
'CBLOB' =>
string(0) ""
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 21:00:01 2025 UTC |
Thanks very much for the fast reply. It works but a new issue is introduced, now the TEXT types are returned always as NULL even when they contain a not NULL value. Test script: --------------- // $con has a valid PDO_INFORMIX connection. $sql = 'create table t1 ( ctext text )'; $con->exec($sql); $sql = "insert into t1 ( ctext ) values (?)"; $stmt = $con->prepare($sql); $stmt->bindValue(1, 'text_value'); $stmt->execute(); $stmt = $con->prepare('select ctext from t1'); $stmt->execute(); $ctext = null; $stmt->bindColumn(1, $ctext, PDO::PARAM_LOB); $stmt->fetch(PDO::FETCH_BOUND); if (is_resource($ctext)) { $ctext = stream_get_contents($value); } var_dump($ctext);