fix oci_bind_array_by_name() with SQLT_ODT type

fix tests
This commit is contained in:
Antony Dovgal 2006-11-23 15:23:10 +00:00
parent 5d9c6b33d0
commit afd25b61a4
5 changed files with 66 additions and 5 deletions

View 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 */

View 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

View 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

View 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

View 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