mirror of
https://github.com/php/php-src.git
synced 2024-11-28 12:26:37 +08:00
Fixed bug #23898 (Proper handling of NULLs in odbc_result, odbc_fetch_into
and odbc_result_all)
This commit is contained in:
parent
209bba391b
commit
ded4aadde0
@ -1438,7 +1438,7 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
|
||||
if (rc == SQL_SUCCESS_WITH_INFO) {
|
||||
Z_STRLEN_P(tmp) = result->longreadlen;
|
||||
} else if (result->values[i].vallen == SQL_NULL_DATA) {
|
||||
Z_STRVAL_P(tmp) = empty_string;
|
||||
ZVAL_NULL(tmp);
|
||||
break;
|
||||
} else {
|
||||
Z_STRLEN_P(tmp) = result->values[i].vallen;
|
||||
@ -1448,7 +1448,7 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
|
||||
|
||||
default:
|
||||
if (result->values[i].vallen == SQL_NULL_DATA) {
|
||||
Z_STRVAL_P(tmp) = empty_string;
|
||||
ZVAL_NULL(tmp);
|
||||
break;
|
||||
}
|
||||
Z_STRLEN_P(tmp) = result->values[i].vallen;
|
||||
@ -1820,7 +1820,10 @@ PHP_FUNCTION(odbc_result)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (result->values[field_ind].vallen == SQL_NULL_DATA || rc == SQL_NO_DATA_FOUND) {
|
||||
if (result->values[field_ind].vallen == SQL_NULL_DATA) {
|
||||
efree(field);
|
||||
RETURN_NULL();
|
||||
} else if (rc == SQL_NO_DATA_FOUND) {
|
||||
efree(field);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@ -1836,7 +1839,7 @@ PHP_FUNCTION(odbc_result)
|
||||
|
||||
default:
|
||||
if (result->values[field_ind].vallen == SQL_NULL_DATA) {
|
||||
RETURN_FALSE;
|
||||
RETURN_NULL();
|
||||
} else {
|
||||
RETURN_STRINGL(result->values[field_ind].value, result->values[field_ind].vallen, 1);
|
||||
}
|
||||
@ -1862,7 +1865,7 @@ PHP_FUNCTION(odbc_result)
|
||||
|
||||
if (result->values[field_ind].vallen == SQL_NULL_DATA) {
|
||||
efree(field);
|
||||
RETURN_FALSE;
|
||||
RETURN_NULL();
|
||||
}
|
||||
/* chop the trailing \0 by outputing only 4095 bytes */
|
||||
PHPWRITE(field,(rc == SQL_SUCCESS_WITH_INFO) ? 4095 :
|
||||
@ -1969,7 +1972,7 @@ PHP_FUNCTION(odbc_result_all)
|
||||
if (rc == SQL_SUCCESS_WITH_INFO)
|
||||
php_printf(buf,result->longreadlen);
|
||||
else if (result->values[i].vallen == SQL_NULL_DATA) {
|
||||
php_printf(" </td>");
|
||||
php_printf("<td>NULL</td>");
|
||||
break;
|
||||
} else {
|
||||
php_printf(buf, result->values[i].vallen);
|
||||
@ -1978,7 +1981,7 @@ PHP_FUNCTION(odbc_result_all)
|
||||
break;
|
||||
default:
|
||||
if (result->values[i].vallen == SQL_NULL_DATA) {
|
||||
php_printf("<td> </td>");
|
||||
php_printf("<td>NULL</td>");
|
||||
} else {
|
||||
php_printf("<td>%s</td>", result->values[i].value);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user