]> granicus.if.org Git - php/commitdiff
Collection fix. getelem method now handles returning nulls
authorAndy Sautins <asautins@php.net>
Sun, 16 Sep 2001 21:53:58 +0000 (21:53 +0000)
committerAndy Sautins <asautins@php.net>
Sun, 16 Sep 2001 21:53:58 +0000 (21:53 +0000)
correctly and gives warning when accessing an index that does
not exist.

ext/oci8/oci8.c

index b7565c5d5f4aaeab57b39611563bd8b4cc94793b..d92c59430752fd813e65b086fb54e5b87d42bb86 100644 (file)
@@ -4604,7 +4604,7 @@ PHP_FUNCTION(ocicollgetelem)
        ub4  ndx;
        int inx;
        dvoid *elem;
-       dvoid *elemind;
+       OCIInd elemind;
        boolean exists;
        OCIString *ocistr = (OCIString *)0;
        text *str;
@@ -4632,18 +4632,24 @@ PHP_FUNCTION(ocicollgetelem)
                                        ndx, 
                                        &exists, 
                                        &elem, 
-                                       &elemind));
+                                       (dvoid **)&elemind));
 
                if (connection->error) {
                        oci_error(connection->pError, "OCICollGetElem", connection->error);
-                       RETURN_FALSE;
+                       RETURN_NULL();
                }
                
                /* Return false if value does not exist at that location */
                if(exists == 0) {
+                       php_error(E_WARNING, "OCICollGetElem - Invalid index %d", ndx);
                        RETURN_FALSE;
                }
 
+               /* Return null if the value is null */
+               if(elemind == OCI_IND_NULL) {
+                       RETURN_FALSE;
+               } 
+
                switch (coll->element_typecode) {
                   case OCI_TYPECODE_DATE:
                           len = 1024;