diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index ead26659c2f..9c149ef0e41 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -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(" "); + php_printf("NULL"); 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(" "); + php_printf("NULL"); } else { php_printf("%s", result->values[i].value); }