ZF-5927: Zend_Db_Statement_Oracle::fetch() doesn't return nulls

Issue Type: Improvement Created: 2009-03-02T19:37:38.000+0000 Last Updated: 2009-03-08T04:23:23.000+0000 Status: Resolved Fix version(s): - 1.7.7 (16/Mar/09)

Reporter: Stefan Alexandru (acid24) Assignee: Mickael Perraud (mikaelkael) Tags: - Zend_Db_Adapter_Oracle

Related issues: Attachments:


The second parameter for oci_fetch_array() is hardcoded, when calling this function inside Zend_Db_Statement_Oracle::fetch(). As a result when the fetchMode property of the database adapter is set to any of Zend_Db::FETCH_NUM, Zend_Db::FETCH_ASSOC, Zend_Db::FETCH_BOTH or Zend_Db::FETCH_BOUND the returned row doesn't contain the columns that have null values.

Maybe this can be made configurable (of course Zend_Db_Statement_Oracle class can be extended and the fetch() method overridden, but I think it would much nicer to allow client code to specify additional flags for the second parameter of the oci_fetch_array() function.

The problem code is written below:

<pre class="highlight">
switch ($style) {
            case Zend_Db::FETCH_NUM:
                $row = oci_fetch_array($this->_stmt, OCI_NUM | $lob_as_string);
            case Zend_Db::FETCH_ASSOC:
                $row = oci_fetch_array($this->_stmt, OCI_ASSOC | $lob_as_string);
            case Zend_Db::FETCH_BOTH:
                $row = oci_fetch_array($this->_stmt, OCI_BOTH | $lob_as_string);
            case Zend_Db::FETCH_OBJ:
                $row = oci_fetch_object($this->_stmt);
            case Zend_Db::FETCH_BOUND:
                $row = oci_fetch_array($this->_stmt, OCI_BOTH | $lob_as_string);
                if ($row !== false) {
                    return $this->_fetchBound($row);
                 * @see Zend_Db_Adapter_Oracle_Exception
                require_once 'Zend/Db/Statement/Oracle/Exception.php';
                throw new Zend_Db_Statement_Oracle_Exception(
                        'code'    => 'HYC00',
                        'message' => "Invalid fetch mode '$style' specified"


Posted by Mickael Perraud (mikaelkael) on 2009-03-03T01:18:01.000+0000

Exactly the same for me today. Ralph, I will correct this like I already did for LOB_AS_STRING. But in my idea, default state is activation of OCI_RETURN_NULLS and deactivation if needed. What do you think about it?

Posted by Helgi Hrafn Halldórsson (harabanar) on 2009-03-06T05:31:08.000+0000

I got in to the same problem as listed above, but this does not affect version 1.6.0 or 1.6.2

I agree with Mickael Perraud, that OCI_RETURN_NULLS should be set by default and deactivated if needed.

I will still use 1.6.2 until this is fixed :S

Posted by Mickael Perraud (mikaelkael) on 2009-03-07T08:43:43.000+0000

Fixed in SVN 14241 and merge back to 1.7 branch in SVN 14242

With correction of ZF-5146, I exchanged oci_fetch_row and oci_fetch_assoc with oci_fetch_array. The normal behaviour of oci_fetch_row and oci_fecth_assoc is to return null for empty field but not for oci_fetch_array. This behaviour wasn't cover by unit test. This is now ok with SVN 14241.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.