Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-197

OCI8 does handle CLOBS differently than all PDO drivers

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical 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');
      

        Activity

        Hide
        Benjamin Eberlei added a comment -

        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.

        Show
        Benjamin Eberlei added a comment - 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.
        Hide
        Benjamin Eberlei added a comment -

        Hm, the simple addition of the OCI_RETURN_LOBS constant seemed to work. That easy? We'll see!

        Show
        Benjamin Eberlei added a comment - Hm, the simple addition of the OCI_RETURN_LOBS constant seemed to work. That easy? We'll see!
        Hide
        Roman S. Borschel added a comment -

        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 OCI_RETURN_LOBS or not.

        So I think the current behavior is fine as a start. There is nothing better and simpler that works right now.

        Show
        Roman S. Borschel added a comment - 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 OCI_RETURN_LOBS or not. So I think the current behavior is fine as a start. There is nothing better and simpler that works right now.
        Hide
        Benjamin Eberlei added a comment -

        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.

        Show
        Benjamin Eberlei added a comment - 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.

          People

          • Assignee:
            Roman S. Borschel
            Reporter:
            Benjamin Eberlei
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: