Bug #46728 [Com]: PDO(OCI)::fetchAll with stream (CLOB) : resource contains always same value

From: Date: Fri, 19 Nov 2021 22:32:48 +0000
Subject: Bug #46728 [Com]: PDO(OCI)::fetchAll with stream (CLOB) : resource contains always same value
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237881@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=46728&edit=1 ID: 46728 Comment by: michael dot vorisek at email dot cz Reported by: berlioz at nicematin dot fr Summary: PDO(OCI)::fetchAll with stream (CLOB) : resource contains always same value Status: No Feedback Type: Bug Package: PDO OCI Operating System: Linux (All ?) PHP Version: 5.2.6 Block user comment: N Private report: N New Comment: Please reopen, I can confirm this issue and the behaviour described in the last post - when multiple rows are selected using fetchAll, the CLOB column value is the same/"" (or null) for all rows. When I restrict a select condition to select only one row, CLOB column has different/correct value than when the result when all rows are selected. Very dangerous bug, must be fixed asap. Previous Comments: ------------------------------------------------------------------------ [2020-03-31 18:13:30] diogotbrito at gmail dot com This BUG also affects db2(pdo_ibm). Works: $pdo = new PDO("ibm:HOSTNAME=xxx;DATABASE=SAMPLE;PORT=10099", "db2admin", "lookupsc.1"); $val = file_get_contents("fundo1.png"); $stm = $pdo->prepare("UPDATE DB2ADMIN.PICTURES SET IMAGEM = :field_blob"); $stm->bindParam(":field_blob", $val, PDO::PARAM_LOB); $stm->execute(); $stm = $pdo->query("SELECT IMAGEM FROM DB2ADMIN.PICTURES"); foreach($stm->fetch(PDO::FETCH_NUM ) as $row) { $a = stream_get_contents($row); var_dump($a); } Outputs: the binary: string(877) "�PNG  IHDR� .... Doesnt't Works: $pdo = new PDO("ibm:HOSTNAME=xxx;DATABASE=SAMPLE;PORT=10099", "db2admin", "lookupsc.1"); $val = file_get_contents("fundo1.png"); $stm = $pdo->prepare("UPDATE DB2ADMIN.PICTURES SET IMAGEM = :field_blob"); $stm->bindParam(":field_blob", $val, PDO::PARAM_LOB); $stm->execute(); $stm = $pdo->query("SELECT IMAGEM FROM DB2ADMIN.PICTURES"); foreach($stm->fetchAll(PDO::FETCH_NUM ) as $row) { $a = stream_get_contents($row[0]); var_dump($a); } Outputs: string(0) "" ------------------------------------------------------------------------ [2017-01-12 07:40:13] anatoly dot rugalev at gmail dot com This bug still exist in PHP 5.6.26 Workaround: $result = []; while ($row = $this->pdoStatement->fetch($fetchMode)) { foreach ($row as $name => $value) { if (is_resource($value)) { $row[$name] = stream_get_contents($value); } } $result[] = $row; } ------------------------------------------------------------------------ [2009-05-03 01:00:19] php-bugs at lists dot php dot net No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". ------------------------------------------------------------------------ [2009-04-25 15:23:18] jani@php.net So is this a bug or not? If it's a missing feature, please change the category. If this is bug and still exists in PHP 5.2.9, please update the version field. ------------------------------------------------------------------------ [2009-02-22 04:50:15] crescentfreshpot at yahoo dot com Sorry, I meant: It seems there is no way to get oci_fetch_all (and presumably PDO_OCI since it uses the same oci.c api) return lob data as separate, individual streams. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=46728 -- Edit this bug report at https://bugs.php.net/bug.php?id=46728&edit=1

« previous php.bugs (#237881) next »