iliaa Fri May 30 10:44:15 2003 EDT Modified files: /php4/ext/odbc php_odbc.c Log: Fixed bug #23898 (Proper handling of NULLs in odbc_result, odbc_fetch_into and odbc_result_all) Index: php4/ext/odbc/php_odbc.c diff -u php4/ext/odbc/php_odbc.c:1.161 php4/ext/odbc/php_odbc.c:1.162 --- php4/ext/odbc/php_odbc.c:1.161 Thu May 1 20:40:20 2003 +++ php4/ext/odbc/php_odbc.c Fri May 30 10:44:15 2003 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_odbc.c,v 1.161 2003/05/02 00:40:20 sniper Exp $ */ +/* $Id: php_odbc.c,v 1.162 2003/05/30 14:44:15 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1438,7 +1438,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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); }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php