Re: Getting blobs out of Oracle

From: Date: Fri, 23 Jun 2000 11:22:33 +0000
Subject: Re: Getting blobs out of Oracle
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-589@lists.php.net to get a copy of this message
On Fri, Jun 23, 2000 at 11:56:51AM +0100, David Newcomb wrote: > > Hi there, > > Having a bit of trouble with getting BLOBs out of Oracle 8, and was > wandering if > anyone has managed to do it. Does it sound familiar? > > I have had a try but there is so little documentation in this area that > I am going around in circles and confusing myself. Could someone > give me a hand, please? do: $conn = ociplogon("u","p"); stmt = ociparse($conn,"select clob from thieso where id = 1"); ociexecute($stmt); ocifetchinto($stmt, &$arr,OCI_ASSOC); echo $arr["CLOB"]->load(); // prints out content of the LOB tc > > Given an Oracle table: > create table upload ( > id number(10), > the_blob blob ); > > > <?php > > // Download > /* This script demonstrates file download to LOB columns > * The formfield used for this example looks like this > */ > if(!isset($lob_download) || $lob_upload == 'none'){ > ?> > > <form action="<?php echo $PHP_SELF; ?>" method="get"> > Download id: <input type="text" name="lob_download"><br> > <input type="submit" value="Download"> - <input > type="reset"> > </form> > > <?php > > } > else > { > echo "<PRE>\n"; > > $conn = OCILogon("webdb", "webdb"); > $stmt = OCIParse($conn,"select the_blob from upload where id = > $lob_download"); > > $lob = OCINewDescriptor($conn, OCI_D_LOB); > OCIDefineByName($stmt,"the_blob",&$lob); > > OCIExecute($stmt, OCI_DEFAULT); > OCIFetch($stmt); > > $bob = OCIResult($stmt,"THE_BLOB"); > echo "bob=|$bob|<BR>\n"; > list($key,$val) = each($bob); > echo "key=|$key|<br>\n"; > echo "val=|$val|<p>\n\n"; > > $l = $lob; > > $l = $lob; > $len = strlen($lob); > list($key,$val) = each($lob); > echo "key=|$key|<br>\n"; > echo "val=|$val|<p>\n\n"; > > echo "len=|$len|<BR>\n"; > echo "lob=|$lob|<BR>\n"; > echo "l=|$l|<p>\n\n"; > > $lob->free(); > OCIFreeStatement($stmt); > OCILogoff($conn); > > list($key,$val) = each($lob); > echo "key=|$key|<br>\n"; > echo "val=|$val|<p>\n\n"; > > echo "lob=|$lob|<BR>\n"; > echo "l=|$l|<p>\n"; > > echo "</PRE>\n"; > } > > ?> > > Produces the results: > > bob=|Object| > key=|descriptor| > val=|Resource id #6| > > key=|descriptor| > val=|Resource id #5| > > len=|6| > lob=|Object| > l=|Object| > > key=|| > val=|| > > lob=|Object| > l=|Object| > > > Any help would be greatly appreciated. > > David. > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net -- Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!" Digital Collections Phone +49 40 235350 Fax +49 40 23535180 Hammerbrookstr. 93 20097 Hamburg / Germany

« previous php.db (#589) next »