]> granicus.if.org Git - php/commitdiff
Handle assign/append of NULL values to collections correctly. Now
authorAndy Sautins <asautins@php.net>
Tue, 11 Sep 2001 21:03:58 +0000 (21:03 +0000)
committerAndy Sautins <asautins@php.net>
Tue, 11 Sep 2001 21:03:58 +0000 (21:03 +0000)
works consistently with how the rest of the library operates.  If
the value passed in is a null string, the value is set to null

ext/oci8/oci8.c

index 9eee4eba682e81229f63aa02a4df612df7d16ff8..747a02625b96567b1cf047646c10e36e63ffdd1c 100644 (file)
@@ -4458,6 +4458,7 @@ PHP_FUNCTION(ocicollappend)
     OCINumber num;
        OCIString *ocistr = (OCIString *)0;
        OCIInd new_ind = OCI_IND_NOTNULL;
+       OCIInd null_ind = OCI_IND_NULL;
        OCIDate dt;
     int inx;
        double ndx;
@@ -4472,6 +4473,26 @@ PHP_FUNCTION(ocicollappend)
             WRONG_PARAM_COUNT;
         }
 
+               /* 
+                * Handle NULLS.  For consistency with the rest of the OCI8 library, when
+                * a value passed in is a 0 length string, consider it a null
+                */
+               convert_to_string_ex(arg);
+               if((*arg)->value.str.len == 0) {
+                       CALL_OCI_RETURN(connection->error, OCICollAppend(
+                                 OCI(pEnv), 
+                                 connection->pError, 
+                                 (dword *)0, 
+                                 &null_ind, 
+                                 coll->coll));
+                       if (connection->error) {
+                               oci_error(connection->pError, "OCICollAppend - NULL", connection->error);
+                               RETURN_FALSE;
+                       }
+
+                       RETURN_TRUE;
+               }
+
                switch(coll->element_typecode) {
                   case OCI_TYPECODE_DATE:
                           convert_to_string_ex(arg);
@@ -4719,6 +4740,7 @@ PHP_FUNCTION(ocicollassignelem)
        oci_collection *coll;
        OCINumber num;
        OCIInd new_ind = OCI_IND_NOTNULL;
+       OCIInd null_ind = OCI_IND_NULL;
        ub4  ndx;
        int inx;
        OCIString *ocistr = (OCIString *)0;
@@ -4743,6 +4765,29 @@ PHP_FUNCTION(ocicollassignelem)
                        oci_error(connection->pError, "OCICollAssignElem", connection->error);
                        RETURN_FALSE;
                }
+
+               /* 
+                * Handle NULLS.  For consistency with the rest of the OCI8 library, when
+                * a value passed in is a 0 length string, consider it a null
+                */
+               convert_to_string_ex(val);
+
+               if((*val)->value.str.len == 0) {
+                       CALL_OCI_RETURN(connection->error, OCICollAssignElem(
+                                 OCI(pEnv), 
+                                 connection->pError, 
+                                 ndx, 
+                                 (dword *)0, 
+                                 &null_ind, 
+                                 coll->coll));
+                       if (connection->error) {
+                               oci_error(connection->pError, "OCICollAssignElem - NULL", connection->error);
+                               RETURN_FALSE;
+                       }
+
+                       RETURN_TRUE;
+               }
+
                switch(coll->element_typecode) {
                   case OCI_TYPECODE_DATE:
                           convert_to_string_ex(val);