Jira issue originally created by user @beberlei:
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.
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);
And use temporary LOBs for update/insert:
Temporary LOBs make some operations easier. Inserting data with a Temporary LOB does not use a
RETURNING INTO clause:
Script 70: tempblobinsert.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->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');
Comment created by @beberlei:
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.
Hm, the simple addition of the OCIRETURNLOBS constant seemed to work. That easy? We'll see!
Issue was closed with resolution "Fixed"
Comment created by romanb:
The current solution is fine as a start. Its just that this setting also affects blobs.
This gets problematic whenever a clob/blob is very large, in which case its not really good to load it all at once. We probably need new types for this stuff.
1) a ClobType
2) a BlobType
both being represented by some kind of object that wraps the platform differences.
However, its not easy to propagate to the driver whetner to use OCIRETURNLOBS or not.
So I think the current behavior is fine as a start. There is nothing better and simpler that works right now.
PDO handles BLOB vs CLOB differently afaik, i can't tell for sure though. I think for BLOBs pdo returns a file pointer, CLOBs are returned as string.
Now how PDO recognizes the difference for example in the case of oracle is probably not configurable for the enduser.