cvs: php4 /ext/pgsql pgsql.c php_pgsql.h

From: Date: Thu, 17 Oct 2002 07:58:47 +0000
Subject: cvs: php4 /ext/pgsql pgsql.c php_pgsql.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-14989@lists.php.net to get a copy of this message
yohgaki Thu Oct 17 03:58:47 2002 EDT Modified files: /php4/ext/pgsql pgsql.c php_pgsql.h Log: Added async message function - pg_get_notify() Index: php4/ext/pgsql/pgsql.c diff -u php4/ext/pgsql/pgsql.c:1.235 php4/ext/pgsql/pgsql.c:1.236 --- php4/ext/pgsql/pgsql.c:1.235 Sun Oct 13 05:48:18 2002 +++ php4/ext/pgsql/pgsql.c Thu Oct 17 03:58:46 2002 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pgsql.c,v 1.235 2002/10/13 09:48:18 yohgaki Exp $ */ +/* $Id: pgsql.c,v 1.236 2002/10/17 07:58:46 yohgaki Exp $ */ #include <stdlib.h> @@ -114,6 +114,8 @@ PHP_FE(pg_field_type, NULL) PHP_FE(pg_field_prtlen, NULL) PHP_FE(pg_field_is_null,NULL) + /* async message function */ + PHP_FE(pg_get_notify, NULL) /* error message functions */ PHP_FE(pg_result_error, NULL) PHP_FE(pg_last_error, NULL) @@ -3004,6 +3006,44 @@ } } /* }}} */ + + +/* {{{ proto resource pg_get_notify([resource connection[, result_type]]) + Get asynchronous notification */ +PHP_FUNCTION(pg_get_notify) +{ + zval *pgsql_link; + int id = -1, result_type = PGSQL_ASSOC; + PGconn *pgsql; + PGresult *pgsql_result; + PGnotify *pgsql_notify; + pgsql_result_handle *pg_result; + + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "r|l", + &pgsql_link) == FAILURE) { + RETURN_FALSE; + } + + ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink); + + PQconsumeInput(pgsql); + pgsql_notify = PQnotifies(pgsql); + if (!pgsql_notify) { + /* no notify message */ + RETURN_FALSE; + } + array_init(return_value); + if (result_type & (PGSQL_NUM|PGSQL_BOTH)) { + add_index_string(return_value, 0, pgsql_notify->relname, 1); + add_index_long(return_value, 1, pgsql_notify->be_pid); + } + if (result_type & (PGSQL_ASSOC|PGSQL_BOTH)) { + add_assoc_string(return_value, "message", pgsql_notify->relname, 1); + add_assoc_long(return_value, "pid", pgsql_notify->be_pid); + } +} +/* }}} */ + /* {{{ php_pgsql_meta_data * TODO: Add meta_data cache for better performance Index: php4/ext/pgsql/php_pgsql.h diff -u php4/ext/pgsql/php_pgsql.h:1.54 php4/ext/pgsql/php_pgsql.h:1.55 --- php4/ext/pgsql/php_pgsql.h:1.54 Sun Oct 13 05:37:27 2002 +++ php4/ext/pgsql/php_pgsql.h Thu Oct 17 03:58:46 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pgsql.h,v 1.54 2002/10/13 09:37:27 yohgaki Exp $ */ +/* $Id: php_pgsql.h,v 1.55 2002/10/17 07:58:46 yohgaki Exp $ */ #ifndef PHP_PGSQL_H #define PHP_PGSQL_H @@ -97,6 +97,8 @@ PHP_FUNCTION(pg_field_type); PHP_FUNCTION(pg_field_prtlen); PHP_FUNCTION(pg_field_is_null); +/* async message functions */ +PHP_FUNCTION(pg_get_notify); /* error message functions */ PHP_FUNCTION(pg_result_error); PHP_FUNCTION(pg_last_error);

« previous php.cvs (#14989) next »