Tuesday, November 4, 2008

PHP Source Code »Using Large Objects in OCI8

In PHP
, LOBs are manipulated using a descriptor. To show this, in SQL*Plus create a table
that has a BLOB column:
SQL> create table mybtab (blobid number, blobdata blob);
PHP code
to insert data into this table is:
navioo_blobinsert.php

$c = oci_connect('hr', 'hrpwd', '//localhost/XE');
$myblobid = 123;
$myv = 'a very large amount of binary data';
$lob = oci_new_descriptor($c, OCI_B_LOB);
$s = oci_parse($c,
'INSERT INTO mybtab (blobid, blobdata) '
. 'VALUES(:myblobid, EMPTY_BLOB()) '
. 'RETURNING blobdata INTO :blobdata');
oci_bind_by_name($s, ':MYBLOBID', $myblobid);
oci_bind_by_name($s, ':BLOBDATA', $lob, -1, OCI_B_BLOB);
oci_execute($s, OCI_DEFAULT);
$lob->save($myv);
oci_commit($c);
?>


Read all..

No comments: