ID:               41877
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jarismar at adplabs dot com dot br
 Status:           Feedback
 Bug Type:         PDO related
 Operating System: Windows
 PHP Version:      5.2.3
 New Comment:

Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.

Wrong button. sorry.


Previous Comments:
------------------------------------------------------------------------

[2007-07-02 20:21:08] jarismar at adplabs dot com dot br

Running the script from command line seems to work fine.
Apache version is 2.0.59 I'll trying an upgrade.

------------------------------------------------------------------------

[2007-07-02 20:04:09] jarismar at adplabs dot com dot br

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.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=41877&edit=1

Reply via email to