From: Frank M. Kromann Date: Mon, 29 Oct 2001 23:41:15 +0000 (+0000) Subject: Reset the error (or message) from the server when calling fetch_row functions. X-Git-Tag: ChangeLog~480 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=75b32c64ffc8c379789f98f22ebfec9f99258f01;p=php Reset the error (or message) from the server when calling fetch_row functions. If the user conected and changed the database the message from the change was reported when the user checked the error function after a failed fetch. This cased problems in PEAR/DB. If the fetch fails for other resons than a fetch after the last row, the message from the server will still be reported. --- diff --git a/ext/mssql/php_mssql.c b/ext/mssql/php_mssql.c index cf4c655f40..e5f85125e5 100644 --- a/ext/mssql/php_mssql.c +++ b/ext/mssql/php_mssql.c @@ -156,7 +156,9 @@ static int php_mssql_message_handler(DBPROCESS *dbproc, DBINT msgno,int msgstate if (severity >= MS_SQL_G(min_message_severity)) { php_error(E_WARNING,"MS SQL message: %s (severity %d)", msgtext, severity); } - STR_FREE(MS_SQL_G(server_message)); + if (MS_SQL_G(server_message)) { + STR_FREE(MS_SQL_G(server_message)); + } MS_SQL_G(server_message) = estrdup(msgtext); return 0; } @@ -1110,7 +1112,12 @@ PHP_FUNCTION(mssql_free_result) Gets the last message from the MS-SQL server */ PHP_FUNCTION(mssql_get_last_message) { - RETURN_STRING(MS_SQL_G(server_message),1); + if (MS_SQL_G(server_message)) { + RETURN_STRING(MS_SQL_G(server_message),1); + } + else { + RETURN_STRING(empty_string,1); + } } /* }}} */ @@ -1182,6 +1189,11 @@ static void php_mssql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type) ZEND_FETCH_RESOURCE(result, mssql_result *, mssql_result_index, -1, "MS SQL-result", le_result); + if (MS_SQL_G(server_message)) { + STR_FREE(MS_SQL_G(server_message)); + MS_SQL_G(server_message) = NULL; + } + if (result->cur_row >= result->num_rows) { RETURN_FALSE; } @@ -1624,7 +1636,7 @@ PHP_FUNCTION(mssql_result) } /* }}} */ -/* {{{ proto string mssql_next_result(int result_id) +/* {{{ proto bool mssql_next_result(int result_id) Move the internal result pointer to the next result */ PHP_FUNCTION(mssql_next_result) {