mssql_query not updating mssql_get_last_message on php4.1.2 and freetds 0.53

Dave Brotherstone davegb at pobox.com
Tue Jun 4 13:21:54 EDT 2002


I submitted a patch that keeps PHP error messages separate, and stores the
error number to the PHP-DEV list a while back - I tried a repost but it's
still not gone in.  Perhaps someone here with a bit more clout on the
php-dev list could post any one of the suggested patches to php-dev, as it
seems there are a number of people (like me) who apply their own patch for
each release?

Dave.

--
Q: What is the most used NT/2000/XP admin tool?
A: A car.


> -----Original Message-----
> From: bounce-freetds-139968 at franklin.oit.unc.edu
> [mailto:bounce-freetds-139968 at franklin.oit.unc.edu]On Behalf Of Mark
> Gruetzner
> Sent: 31 May 2002 05:27
> To: TDS Development Group
> Subject: [freetds] RE: mssql_query not updating mssql_get_last_message
> on php4.1.2 and freetds 0.53
>
>
> Sure...I submitted it and I hope it will help...the request id is 562746
>
> -Mark
>
> -----Original Message-----
> From: bounce-freetds-143882 at franklin.oit.unc.edu
> [mailto:bounce-freetds-143882 at franklin.oit.unc.edu]On Behalf Of James K.
> Lowden
> Sent: Thursday, May 30, 2002 7:05 PM
> To: TDS Development Group
> Subject: [freetds] RE: mssql_query not updating mssql_get_last_message
> on php4.1.2 and freetds 0.53
>
>
> On Thu, 30 May 2002 10:05:52 -0500 "Mark Gruetzner" <mgruetzner at rw3.com>
> wrote:
> >
> > I have another, related patch for php 4.1.2 (and I haven't seen it fixed
> > in the latest stable build of php either).  The patch below is the
> > entire"sybase_query" function in the php_sybase_db.c file.  Search for
> > //fixfix to see what I added.  This patch allows the actual error
> > message to be sent to php to update the return value for
> > mssql_get_last_message every time raiserror is called with a
> > user-defined message, such as raiserror ('My error message',9,1):
>
> Mark,
>
> Could you please convert this to a universal diff and post it to FreeTDS's
> patches on sourceforge?  Then I could update the UG to point it out to
> people who read the docs and not the list.  I think that would help a lot
> of people, potentially.
>
> Much obliged. :^)
>
> --jkl
>
>
> ---
> You are currently subscribed to freetds as: [mgruetzner at rw3.com]
> To unsubscribe, forward this message to
> $subst('Email.Unsub')
>
>
> ---
> You are currently subscribed to freetds as: [davegb at pobox.com]
> To unsubscribe, forward this message to
> $subst('Email.Unsub')
>
>
-------------- next part --------------
Index: ext/sybase/php_sybase_db.c
===================================================================
RCS file: /repository/php4/ext/sybase/php_sybase_db.c,v
retrieving revision 1.37
diff -u -r1.37 php_sybase_db.c
--- ext/sybase/php_sybase_db.c	12 Mar 2002 20:18:00 -0000	1.37
+++ ext/sybase/php_sybase_db.c	22 May 2002 13:37:43 -0000
@@ -88,6 +88,8 @@
 	PHP_FE(sybase_query,			NULL)
 	PHP_FE(sybase_free_result,		NULL)
 	PHP_FE(sybase_get_last_message,	NULL)
+	PHP_FE(sybase_get_last_error,	NULL)
+	PHP_FE(sybase_get_last_error_no,	NULL)
 	PHP_FE(sybase_num_rows,			NULL)
 	PHP_FE(sybase_num_fields,		NULL)
 	PHP_FE(sybase_fetch_row,		NULL)
@@ -107,6 +109,8 @@
 	PHP_FALIAS(mssql_query,			sybase_query,			NULL)
 	PHP_FALIAS(mssql_free_result,	sybase_free_result,		NULL)
 	PHP_FALIAS(mssql_get_last_message,	sybase_get_last_message,	NULL)
+	PHP_FALIAS(mssql_get_last_error,	sybase_get_last_error,	NULL)
+	PHP_FALIAS(mssql_get_last_error_no,	sybase_get_last_error_no,	NULL)
 	PHP_FALIAS(mssql_num_rows,		sybase_num_rows,		NULL)
 	PHP_FALIAS(mssql_num_fields,	sybase_num_fields,		NULL)
 	PHP_FALIAS(mssql_fetch_row,		sybase_fetch_row,		NULL)
@@ -146,6 +150,9 @@
 	if (severity >= php_sybase_module.min_error_severity) {
 		php_error(E_WARNING,"Sybase error:  %s (severity %d)",dberrstr,severity);
 	}
+	STR_FREE(php_sybase_module.error_message);
+	php_sybase_module.error_message = estrdup(dberrstr);
+	php_sybase_module.error_no = dberr;
 	return INT_CANCEL;  
 }
 
@@ -279,8 +286,10 @@
 {
 	php_sybase_module.default_link=-1;
 	php_sybase_module.num_links = php_sybase_module.num_persistent;
-	php_sybase_module.appname = estrndup("PHP 4.0",7);
+	php_sybase_module.appname = estrndup("PHP 4.2",7);
 	php_sybase_module.server_message = empty_string;
+	php_sybase_module.error_message = empty_string;
+	php_sybase_module.error_no = 0;
 	php_sybase_module.min_error_severity = php_sybase_module.cfg_min_error_severity;
 	php_sybase_module.min_message_severity = php_sybase_module.cfg_min_message_severity;
 	return SUCCESS;
@@ -296,6 +305,7 @@
 {
 	efree(php_sybase_module.appname);
 	STR_FREE(php_sybase_module.server_message);
+	STR_FREE(php_sybase_module.error_message);
 	return SUCCESS;
 }
 
@@ -940,6 +950,26 @@
 	RETURN_STRING(php_sybase_module.server_message,1);
 }
 /* }}} */
+
+
+/* {{{ proto string sybase_get_last_error(void)
+   Returns the last error message from server */
+PHP_FUNCTION(sybase_get_last_error)
+{
+	RETURN_STRING(php_sybase_module.error_message,1);
+}
+/* }}} */
+
+
+/* {{{ proto string sybase_get_last_error_no(void)
+   Returns the last error number from server */
+PHP_FUNCTION(sybase_get_last_error_no)
+{
+	Z_LVAL_P(return_value) = php_sybase_module.error_no;
+	Z_TYPE_P(return_value) = IS_LONG;
+}
+/* }}} */
+
 
 /* {{{ proto int sybase_num_rows(int result)
    Get number of rows in result */
Index: ext/sybase/php_sybase_db.h
===================================================================
RCS file: /repository/php4/ext/sybase/php_sybase_db.h,v
retrieving revision 1.8
diff -u -r1.8 php_sybase_db.h
--- ext/sybase/php_sybase_db.h	28 Feb 2002 08:26:50 -0000	1.8
+++ ext/sybase/php_sybase_db.h	22 May 2002 13:37:45 -0000
@@ -38,6 +38,8 @@
 PHP_FUNCTION(sybase_query);
 PHP_FUNCTION(sybase_free_result);
 PHP_FUNCTION(sybase_get_last_message);
+PHP_FUNCTION(sybase_get_last_error);
+PHP_FUNCTION(sybase_get_last_error_no);
 PHP_FUNCTION(sybase_num_rows);
 PHP_FUNCTION(sybase_num_fields);
 PHP_FUNCTION(sybase_fetch_row);
@@ -70,6 +72,8 @@
 	long allow_persistent;
 	char *appname;
 	char *server_message;
+	char *error_message;
+	int error_no;
 	int le_link,le_plink,le_result;
 	long min_error_severity,min_message_severity;
 	long cfg_min_error_severity,cfg_min_message_severity;


More information about the FreeTDS mailing list