summaryrefslogtreecommitdiff
path: root/ext/mssql/php_mssql.c
diff options
context:
space:
mode:
authorFrank M. Kromann <fmk@php.net>2001-10-29 23:41:15 +0000
committerFrank M. Kromann <fmk@php.net>2001-10-29 23:41:15 +0000
commit75b32c64ffc8c379789f98f22ebfec9f99258f01 (patch)
tree8966df6a3eedc721ede04e2b4eb6f6c49de40393 /ext/mssql/php_mssql.c
parente9c09b86e10f22c4274df5b645853de9d7b7d5d4 (diff)
downloadphp-git-75b32c64ffc8c379789f98f22ebfec9f99258f01.tar.gz
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.
Diffstat (limited to 'ext/mssql/php_mssql.c')
-rw-r--r--ext/mssql/php_mssql.c18
1 files changed, 15 insertions, 3 deletions
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)
{