cvs: php4 /ext/mssql php_mssql.c
| From: | Frank M. Kromann | Date: | Mon, 29 Oct 2001 23:41:15 +0000 |
| Subject: | cvs: php4 /ext/mssql php_mssql.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-8028@lists.php.net to get a copy of this message | ||
fmk Mon Oct 29 18:41:15 2001 EDT
Modified files:
/php4/ext/mssql php_mssql.c
Log:
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.
Index: php4/ext/mssql/php_mssql.c
diff -u php4/ext/mssql/php_mssql.c:1.71 php4/ext/mssql/php_mssql.c:1.72
--- php4/ext/mssql/php_mssql.c:1.71 Tue Oct 23 12:34:52 2001
+++ php4/ext/mssql/php_mssql.c Mon Oct 29 18:41:15 2001
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_mssql.c,v 1.71 2001/10/23 16:34:52 fmk Exp $ */
+/* $Id: php_mssql.c,v 1.72 2001/10/29 23:41:15 fmk Exp $ */
#ifdef COMPILE_DL_MSSQL
#define HAVE_MSSQL 1
@@ -156,7 +156,9 @@
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 @@
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 @@
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 @@
}
/* }}} */
-/* {{{ 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)
{