note 101841 modified in pdo.lobs by danbrown

From: Date: Thu, 13 Jan 2011 19:13:45 +0000
Subject: note 101841 modified in pdo.lobs by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-175721@lists.php.net to get a copy of this message
I find it easier to use stream_get_contens to fetch the data of a lob using the file handle. <?php $stmt = $pdo->con->prepare( 'select * from filetable' ); $stmt->execute(); $res = $stmt->fetchAll( PDO::FETCH_ASSOC ); for( $i=0; $i<count($res); $i++ ){ $filename = "C:/tmp/".$res[$i]['FILE_ID'].'.xml'; $content = stream_get_contents( $res[$i]['DATA_FILE'] ); file_put_contents( $filename, $content ); } ?> --was-- I find it easier to use stream_get_contens to fetch the data of a lob using the file handle. $stmt = $pdo->con->prepare( 'select * from filetable' ); $stmt->execute(); $res = $stmt->fetchAll( PDO::FETCH_ASSOC ); for( $i=0; $i<count($res); $i++ ){ $filename = "C:/tmp/".$res[$i]['FILE_ID'].'.xml'; $content = stream_get_contents( $res[$i]['DATA_FILE'] ); file_put_contents( $filename, $content ); } http://php.net/manual/en/pdo.lobs.php

« previous php.notes (#175721) next »