|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-07-02 20:21 UTC] jarismar at adplabs dot com dot br
[2007-07-05 13:58 UTC] tony2001@php.net
[2007-07-13 01:00 UTC] php-bugs at lists dot php dot net
[2016-03-08 01:41 UTC] sixd@php.net
-Package: PDO related
+Package: PDO OCI
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 05:00:02 2025 UTC |
Description: ------------ Unable to read BLOBs from a given table and insert on another one, because php hangs up after inserting the first record on destination table. Reproduce code: --------------- SQL: CREATE TABLE TBL_BLOB (id NUMBER(10), data BLOB); CREATE TABLE TBL_BLOB2 (id NUMBER(10), data BLOB); You will need to insert some records on TBL_BLOB. PHP: try { $oPDO = new PDO($sDSN, $sUserName, $sPassword); $oPDO->beginTransaction(); $sSQLRead = 'SELECT ID, DATA FROM TBL_BLOB'; $oStmtRead = $oPDO->prepare($sSQLRead); $oStmtRead->execute(); $sSQLWrite = 'INSERT INTO TBL_BLOB2 (ID, DATA) VALUES (:id, EMPTY_BLOB()) RETURNING DATA INTO :stream'; $oStmtWrite = $oPDO->prepare($sSQLWrite); while (($aRow = $oStmtRead->fetch())) { $iID = $aRow['ID']; $rData = $aRow['DATA']; if (is_resource($rData)) { $sData = stream_get_contents($rData); fclose($rData); } else { throw new Exception('Error fetching stream'); } $oStmtWrite->bindParam(':id', $iID); $oStmtWrite->bindParam(':stream', $resource, PDO::PARAM_LOB); $oStmtWrite->execute(); if (is_resource($resource)) { fwrite($resource, $sData); fclose($resource); } else { throw new Exception('Error fetching stream'); } } $oStmtRead->closeCursor(); $oPDO->commit(); } catch (Exception $oE) { $oPDO->rollBack(); throw $oE; } $oPDO = null; Expected result: ---------------- No output, but TBL_BLOB2 should have same records from TBL_BLOB. Actual result: -------------- Apache hangs up, the page keeps loading forever. Simply trying to debug the script I see no error, the script finishes normally, but Apache does not send any response. Uncommenting the fclose(<stream>) command then debugging, the debugger stops after writing to TBL_BLOB2 on the second record.