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

From: Date: Tue, 31 Mar 2020 18:13:30 +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-226373@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: diogotbrito at gmail dot com 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: 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) "" Previous Comments: ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ [2009-02-22 04:48:09] crescentfreshpot at yahoo dot com Seems similar to bug #37706 I reported in the oci8 module a while back. All my fetched rows would all point to the same (last fetched) lob descriptor. It seems there is no way to stop oci_fetch_all (and presumably PDO_OCI since it uses the same oci.c api) from automatically fetching lob data and return them 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 (#226373) next »