]> granicus.if.org Git - php/commitdiff
fix oci_bind_array_by_name() with SQLT_ODT type
authorAntony Dovgal <tony2001@php.net>
Thu, 23 Nov 2006 15:23:10 +0000 (15:23 +0000)
committerAntony Dovgal <tony2001@php.net>
Thu, 23 Nov 2006 15:23:10 +0000 (15:23 +0000)
fix tests

ext/oci8/oci8_statement.c
ext/oci8/tests/array_bind_001.phpt
ext/oci8/tests/array_bind_003.phpt
ext/oci8/tests/array_bind_date.phpt
ext/oci8/tests/array_bind_date1.phpt

index 36be4dc0161efc168841a2a26e1451225d87dcf5..ee2b8b32225aaa8a2016792aff8823eec6db9663 100644 (file)
@@ -802,7 +802,7 @@ int php_oci_bind_post_exec(void *data TSRMLS_DC)
                                                } else {
                                                        zstr tmp;
                                                        tmp.s = buff;
-                                                       ZVAL_TEXTL(*entry, tmp, buff_len, 1);
+                                                       ZVAL_TEXTL(*entry, tmp, TEXT_CHARS(buff_len), 1);
                                                }
                                                zend_hash_move_forward(hash);
                                        } else {
@@ -813,7 +813,7 @@ int php_oci_bind_post_exec(void *data TSRMLS_DC)
                                                        php_oci_error(connection->err, connection->errcode TSRMLS_CC);
                                                        add_next_index_null(bind->zval);
                                                } else {
-                                                       add_next_index_textl(bind->zval, tmp, buff_len, 1);
+                                                       add_next_index_textl(bind->zval, tmp, TEXT_CHARS(buff_len), 1);
                                                }
                                        }
                                }
@@ -1523,8 +1523,12 @@ php_oci_bind *php_oci_bind_array_helper_date(zval* var, long max_table_length, p
                }
                if ((i < bind->array.current_length) && (zend_hash_get_current_data(hash, (void **) &entry) != FAILURE)) {
                        
-                       convert_to_string_ex(entry);
-                       PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, Z_STRVAL_PP(entry), Z_STRLEN_PP(entry), NULL, 0, NULL, 0, &oci_date));
+                       convert_to_text_ex(entry);
+                       if (UG(unicode)) {
+                               PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, (text *)Z_UNIVAL_PP(entry).s, UBYTES(Z_UNILEN_PP(entry)), NULL, 0, NULL, 0, &oci_date));
+                       } else {
+                               PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, Z_STRVAL_PP(entry), Z_STRLEN_PP(entry), NULL, 0, NULL, 0, &oci_date));
+                       }
 
                        if (connection->errcode != OCI_SUCCESS) {
                                /* failed to convert string to date */
@@ -1538,7 +1542,14 @@ php_oci_bind *php_oci_bind_array_helper_date(zval* var, long max_table_length, p
                        ((OCIDate *)bind->array.elements)[i] = oci_date;
                        zend_hash_move_forward(hash);
                } else {
-                       PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, "01-JAN-00", sizeof("01-JAN-00")-1, NULL, 0, NULL, 0, &oci_date));
+                       
+                       if (UG(unicode)) {
+                               UChar *tmp = USTR_MAKE("01-JAN-00");
+                               PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, (text *)tmp, UBYTES(sizeof("01-JAN-00")-1), NULL, 0, NULL, 0, &oci_date));
+                               efree(tmp);
+                       } else {
+                               PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, "01-JAN-00", sizeof("01-JAN-00")-1, NULL, 0, NULL, 0, &oci_date));
+                       }
 
                        if (connection->errcode != OCI_SUCCESS) {
                                /* failed to convert string to date */
index 1310325ad44b795844c51dcad4063e142ebcb09e..6fa0d11050cc83fa1e40af59b9a272cdb2a11be7 100644 (file)
@@ -67,3 +67,12 @@ array(1) {
   string(0) ""
 }
 Done
+--UEXPECTF--
+Warning: oci_bind_array_by_name(): OCI-21560: argument 3 is null, invalid, or out of range in %s on line %d
+
+Warning: oci_execute(): ORA-01008: not all variables bound in %s on line %d
+array(1) {
+  [0]=>
+  unicode(0) ""
+}
+Done
index 497e46e49600c90a997b817287a4857da33deb38..f1218ca231997b57e5bffb12f937d9f8533a630b 100644 (file)
@@ -71,3 +71,16 @@ array(4) {
   string(9) "26-OCT-17"
 }
 Done
+--UEXPECTF--
+Warning: oci_execute(): OCI_NO_DATA in %s on line %d
+array(4) {
+  [0]=>
+  unicode(9) "06-DEC-05"
+  [1]=>
+  unicode(9) "10-DEC-80"
+  [2]=>
+  unicode(9) "21-AUG-91"
+  [3]=>
+  unicode(9) "26-OCT-17"
+}
+Done
index 63da558f91d0b95f35e9194284602da752afcd39..5c2f5dae8717f9a407e60546096d429fbeddd0de 100644 (file)
@@ -72,3 +72,17 @@ array(5) {
   string(9) "06-DEC-05"
 }
 Done
+--UEXPECT--
+array(5) {
+  [0]=>
+  unicode(9) "05-NOV-05"
+  [1]=>
+  unicode(9) "26-OCT-17"
+  [2]=>
+  unicode(9) "21-AUG-91"
+  [3]=>
+  unicode(9) "10-DEC-80"
+  [4]=>
+  unicode(9) "06-DEC-05"
+}
+Done
index ebf767570b695c5d3b8d7126565c08f387da9dae..21725d40f93f93c6351108f3978fb7395d4dd196 100644 (file)
@@ -72,3 +72,17 @@ array(5) {
   string(9) "06-DEC-05"
 }
 Done
+--UEXPECT--
+array(5) {
+  [0]=>
+  unicode(9) "05-NOV-05"
+  [1]=>
+  unicode(9) "26-OCT-17"
+  [2]=>
+  unicode(9) "21-AUG-91"
+  [3]=>
+  unicode(9) "10-DEC-80"
+  [4]=>
+  unicode(9) "06-DEC-05"
+}
+Done