Alf, This is an exerpt from a paper "Making efficient use of Oracle8i thru Apache and PHP 4, Thies C. Arntzen <thies@xxxxxxxxxx> 2001" describing PHP and Oracle LOBs. You should be able to port the code to PHP5 relatively easily. Regards, Neil Morgan large objects ============= PHP has full support for using internal and external LOBs in oracle. LOBs are different from "normal" data-types as they require extra programming on the script side. when you need to store large amount of data in one field LOBs are the ideal choice. you could also store bigger fields (up to 2GB) in a "LONG" or "LONG RAW" field (which is as good supported be PHP) but oracle plans to drop support for those types in future releases. "LONG" and "LONG RAW" fields can not be replicated across servers and they will always get loaded into memory when the row containing the "LONG" or "LONG RAW" is touched. LOBs don't have this limitation but cause a tiny bit more headache when used. oracle has CLOBs (character-LOB) BLOBs (binary-LOB) and BFILEs (external files - only path to file is stored in database). before you can use a LOB oracle needs to create it - lets illustrate: blobdemo.sql create table blobdemo (id number, lob blob); <?php $data = array("/lib/libc-2.2.2.so","/lib/libncurses.so.5.2"); $db = OCILogon("scott","tiger"); $stmt = OCIParse($db,"insert into blobdemo values (myid.nextval,EMPTY_BLOB()) returning id,lob into :id,:lob"); $lob = OCINewDescriptor($db); OCIBindByName($stmt,":ID",$id,32); OCIBindByName($stmt,":LOB",$lob,-1,SQLT_BLOB); while (list(,$file) = each($data)) { OCIExecute($stmt,OCI_DEFAULT); // we cannot use autocommitt here $lob->save(`cat $file`); echo "$file id:$id\n"; OCICommit($db); } ?> now we have loaded our libc and ncurses into oracle - makes sense;-) getting them back is more trivial: <?php $db = OCILogon("scott","tiger"); $stmt = OCIParse($db,"select * from blobdemo"); OCIExecute($stmt); while (OCIFetchInto($stmt,$arr,OCI_ASSOC)) { echo "id: ".$arr[ "ID" ]."\n"; echo "size: ".strlen($arr[ "LOB" ]->load())."\n"; } ?> to update a lob you have to load the LOB-descriptor first: <?php $db = OCILogon("scott","tiger"); $stmt = OCIParse($db,"select blob from blobdemo for update"); OCIExecute($stmt,OCI_DEFAULT); while (OCIFetchInto($stmt,$arr,OCI_ASSOC)) { $content = $arr[ "LOB" ]->load(); echo "id: ".$arr[ "ID" ]."\n"; echo "size: ".strlen($content)."\n"; $lob->save(strrev($content)); } OCICommit($db); ?> there are functions to just replace a part of a LOB, you can spool a LOB to the browser or a file _without_ buffering it a PHP-variable. the OCIFetchInto function also allows you to inline the LOB values into your result-set, this saves you the call to ->load() but LOB-data which is returned instead of the locator can not be modified like shown above. the oracle-BFILE type can be read like a normal LOB/CLOB but can't be written to. basically you can store the path to a file on the oracle-server in a table-field and the LOB functions allow you to read this file thru the oracle server-connection. this can be extremely helpful if your web-server is in front of a firewall and you only want to allow oracle-traffic thru this firewall (no NFS-traffic). the BFILE allows you to keep your images in the file-system so they don't clutter your table-space but you can still access them as if they were a part of your database! -----Original Message----- From: Alf Stockton [mailto:alf@xxxxxxxxxxxxxx] Sent: 23 May 2007 13:33 To: php windows Subject: Oracle BLOB & PHP Can someone suggest a method whereby one retrieves an Oracle BLOB & subsequently display same on a HTML page? If possible an example would be great. -- Regards, Alf Stockton www.stockton.co.za Don't plan any hasty moves. You'll be evicted soon anyway. My email disclaimer is available at www.stockton.co.za/disclaimer.html -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php