[nycphp-talk] Oracle and gif storage
Patrick Hunt
pat at vote.com
Thu Sep 5 16:34:50 EDT 2002
Bill,
You have to store images as blobs, which means you can't use a
plain old SQL statement.
Here's a simple example:
//$image = {contents of image file};
$sql = "INSERT INTO IMAGE_TABLE (IMAGE_ID, IMAGE)
VALUES ($NewImageID, EMPTY_BLOB()) returning IMAGE into
:img";
$blobdesc = OCINewDescriptor($conn, OCI_D_LOB);
if ($qry = OCIParse($conn, $sql)) {
OCIBindByName($qry, ":img", &$blobdesc, -1, OCI_B_BLOB);
if (OCIExecute($qry, OCI_DEFAULT)){
if ($image) {
$blobdesc->save($image);
}
OCICommit($conn);
}
else {
OCIRollback($conn);
}
OCIFreeStatement($qry);
}
The one thing I don't know how to do is trap errors in the
$blobdesc->save method.
Getting the image back out can be done with a normal SQL select.
Just remember to tell OCIFetchInto to return LOB
columns, as in: OCIFetchInto($qry, &$rslt, OCI_RETURN_LOBS)
Pat
---------------------------------------
On Thu, 5 Sep 2002 14:53:15 -0400, Bill Patterson wrote:
>Has anyone found a practical way to store .GIF files in Oracle (8i) using
>PHP? If so, please get in touch. I am trying to do it and keep running
>into one problem or another. Thanks.
>
>Bill Patterson
>
>
>
>--- Unsubscribe at http://nyphp.org/list ---
>
>
>
More information about the talk
mailing list