From: Andy Sautins Date: Sun, 16 Sep 2001 21:53:58 +0000 (+0000) Subject: Collection fix. getelem method now handles returning nulls X-Git-Tag: PRE_SUBST_Z_MACROS~87 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=16ef3439f40bceb0786ae9177c0f43a4f76b990e;p=php Collection fix. getelem method now handles returning nulls correctly and gives warning when accessing an index that does not exist. --- diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index b7565c5d5f..d92c594307 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -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;