ID: 36851 Updated by: [EMAIL PROTECTED] Reported By: cjbj at hotmail dot com -Status: Open +Status: Assigned Bug Type: OCI8 related Operating System: Linux PHP Version: 5.1.2 -Assigned To: +Assigned To: tony2001
Previous Comments: ------------------------------------------------------------------------ [2006-03-24 22:13:31] cjbj at hotmail dot com Description: ------------ Doc bug 1: oci_fetch_array(). The manual http://www.php.net/manual/en/function.oci-fetch-array.php says oci_fetch_array() returns an array with both associative and numeric indices. Note: This function sets NULL fields to PHP NULL value. My testing shows the default does not return NULLs. The above Note should be removed from the documentation. The manual later says that OCI_RETURN_NULLS is an option. Using this does return NULLs as expected. Code bug 1: oci_fetch_assoc documentation says "Note: This function sets NULL fields to PHP NULL value." This is not true. I'd treat this as a code bug, since it makes it hard to code in some styles - you have to code special case checks for each column since no entry may exist. Also there are no optional parameters to alter the behavior. Code bug 2: oci_fetch_object: same problem as oci_fetch_assoc. Code bug 3: oci_fetch_row: same problem as oci_fetch_assoc. Only oci_fetch_all() honors the documentation and returns NULLs. Reproduce code: --------------- <?php echo "<pre>"; $c = oci_connect("hr", "hr", "//localhost/XE"); $stid = oci_parse($c, "select 'abc', null, 'ghi' from dual"); echo "Fetch All\n"; oci_execute($stid, OCI_DEFAULT); oci_fetch_all($stid, $res); var_dump($res); echo "Fetch as Array\n"; oci_execute($stid, OCI_DEFAULT); $res = oci_fetch_array($stid); var_dump($res); echo "Associative Array\n"; oci_execute($stid, OCI_DEFAULT); $res = oci_fetch_assoc($stid); var_dump($res); echo "Object\n"; oci_execute($stid, OCI_DEFAULT); $res = oci_fetch_object($stid); var_dump($res); echo "Numeric Array\n"; oci_execute($stid, OCI_DEFAULT); $res = oci_fetch_row($stid); var_dump($res); oci_close($c); echo "</pre>"; ?> Actual result: -------------- Fetch All array(3) { ["'ABC'"]=> array(1) { [0]=> string(3) "abc" } ["NULL"]=> array(1) { [0]=> NULL } ["'GHI'"]=> array(1) { [0]=> string(3) "ghi" } } Fetch as Array array(4) { [0]=> string(3) "abc" ["'ABC'"]=> string(3) "abc" [2]=> string(3) "ghi" ["'GHI'"]=> string(3) "ghi" } Associative Array array(2) { ["'ABC'"]=> string(3) "abc" ["'GHI'"]=> string(3) "ghi" } Object object(stdClass)#1 (2) { ["'ABC'"]=> string(3) "abc" ["'GHI'"]=> string(3) "ghi" } Numeric Array array(2) { [0]=> string(3) "abc" [2]=> string(3) "ghi" } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36851&edit=1