Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 2.0-ALPHA3
-
Fix Version/s: 2.0-ALPHA4
-
Component/s: ORM
-
Security Level: All
-
Labels:None
Description
OCI8 returns OCI-LOB objects instead of the clob directly (also for binary large objects) as described by the Underground Manual to PHP and Oracle.
http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf
To accompany for this behaviour we need to use the described methods to directly get access to strings:
// Instead of using locators, LOB data can alternatively be returned as a string:
$arr = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_LOBS);
echo $arr['BLOBDATA'];
And use temporary LOBs for update/insert:
emporary LOBs
Temporary LOBs make some operations easier. Inserting data with a Temporary LOB does not use a
RETURNING INTO clause:
Script 70: tempblobinsert.php
<?php
$c = oci_connect('hr', 'hrpwd', 'localhost/XE');
$myblobid = 124;
$myv = 'a very large amount of binary data';
$s = oci_parse($c, 'insert into mybtab (blobid, blobdata)
values (:myblobid, :blobdata)');
$lob = oci_new_descriptor($c, OCI_D_LOB);
oci_bind_by_name($s, ':myblobid', $myblobid);
oci_bind_by_name($s, ':blobdata', $lob, -1, OCI_B_BLOB);
$lob->writeTemporary($myv, OCI_TEMP_BLOB);
oci_execute($s, OCI_DEFAULT);
oci_commit($c);
$lob->close(); // close lob descriptor to free resources
?>
Temporary LOBs also simplify updating values:
$s = oci_parse($c, 'update mybtab set blobdata = :bd where blobid = :bid');
Added test that fails on Oracle OCI into BasicFunctionalTest TestCase.
I think we should handle CLOBs and BLOBs differently.
a CLOB should be a string by default, however a BLOB on any platform should look like an OCI-LOB instance imho.