cvs: php4 / NEWS /ext/pgsql pgsql.c php_pgsql.h
| From: | Rasmus Lerdorf | Date: | Sun, 06 May 2001 01:35:05 +0000 |
| Subject: | cvs: php4 / NEWS /ext/pgsql pgsql.c php_pgsql.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-5549@lists.php.net to get a copy of this message | ||
rasmus Sat May 5 18:35:05 2001 EDT
Modified files:
/php4 NEWS
/php4/ext/pgsql pgsql.c php_pgsql.h
Log:
Add pg_last_notice() function
Index: php4/NEWS
diff -u php4/NEWS:1.651 php4/NEWS:1.652
--- php4/NEWS:1.651 Sat May 5 09:28:20 2001
+++ php4/NEWS Sat May 5 18:34:51 2001
@@ -1,5 +1,7 @@
PHP 4.0 NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+?? ??? 200?, Version 4.0.7
+- Add pg_last_notice() function (Rasmus from suggestion by Dirk@rackspace.com)
?? ??? 200?, Version 4.0.6
- Fixed a bug in preg_split() that would incorrectly limit the number of
Index: php4/ext/pgsql/pgsql.c
diff -u php4/ext/pgsql/pgsql.c:1.100 php4/ext/pgsql/pgsql.c:1.101
--- php4/ext/pgsql/pgsql.c:1.100 Mon Apr 30 07:23:40 2001
+++ php4/ext/pgsql/pgsql.c Sat May 5 18:34:56 2001
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pgsql.c,v 1.100 2001/04/30 14:23:40 dbeu Exp $ */
+/* $Id: pgsql.c,v 1.101 2001/05/06 01:34:56 rasmus Exp $ */
#include <stdlib.h>
@@ -46,6 +46,7 @@
PHP_FE(pg_pconnect, NULL)
PHP_FE(pg_close, NULL)
PHP_FE(pg_cmdtuples, NULL)
+ PHP_FE(pg_last_notice, NULL)
PHP_FE(pg_dbname, NULL)
PHP_FE(pg_errormessage, NULL)
PHP_FE(pg_trace, NULL)
@@ -145,6 +146,9 @@
PQfinish(link);
PGG(num_persistent)--;
PGG(num_links)--;
+ if(PGG(last_notice) != NULL) {
+ efree(PGG(last_notice));
+ }
}
@@ -155,10 +159,13 @@
if (! PGG(ignore_notices)) {
php_log_err(message);
+ if (PGG(last_notice) != NULL) {
+ efree(PGG(last_notice));
+ }
+ PGG(last_notice) = estrdup(message);
}
}
-
static int _rollback_transactions(zend_rsrc_list_entry *rsrc)
{
PGconn *link = (PGconn *)rsrc->ptr;
@@ -197,6 +204,7 @@
{
PGG(num_persistent) = 0;
PGG(ignore_notices) = 0;
+ PGG(last_notice) = NULL;
}
PHP_MINIT_FUNCTION(pgsql)
@@ -866,6 +874,16 @@
}
/* }}} */
+/* {{{ proto int pg_last_notice(int connection)
+ Returns the last notice set by the backend */
+PHP_FUNCTION(pg_last_notice) {
+ if (PGG(last_notice) == NULL) {
+ RETURN_FALSE;
+ } else {
+ RETURN_STRING(PGG(last_notice),0);
+ }
+}
+/* }}} */
char *get_field_name(PGconn *pgsql, Oid oid, HashTable *list)
{
Index: php4/ext/pgsql/php_pgsql.h
diff -u php4/ext/pgsql/php_pgsql.h:1.29 php4/ext/pgsql/php_pgsql.h:1.30
--- php4/ext/pgsql/php_pgsql.h:1.29 Wed Apr 4 14:40:41 2001
+++ php4/ext/pgsql/php_pgsql.h Sat May 5 18:34:56 2001
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pgsql.h,v 1.29 2001/04/04 21:40:41 thies Exp $ */
+/* $Id: php_pgsql.h,v 1.30 2001/05/06 01:34:56 rasmus Exp $ */
#ifndef PHP_PGSQL_H
#define PHP_PGSQL_H
@@ -64,6 +64,7 @@
PHP_FUNCTION(pg_numrows);
PHP_FUNCTION(pg_numfields);
PHP_FUNCTION(pg_cmdtuples);
+PHP_FUNCTION(pg_last_notice);
PHP_FUNCTION(pg_fieldname);
PHP_FUNCTION(pg_fieldsize);
PHP_FUNCTION(pg_fieldtype);
@@ -120,6 +121,7 @@
long allow_persistent;
int le_lofp,le_string;
int ignore_notices;
+ char *last_notice;
} php_pgsql_globals;