From f5f60e6feaeabf06bba4c4150ae9f80e48c6e39d Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Sun, 27 Jul 2003 16:47:36 +0000 Subject: [PATCH] Added new function pg_parameter_status() --- ext/pgsql/pgsql.c | 38 ++++++++++++++++++++++++++++++++++++++ ext/pgsql/php_pgsql.h | 3 +++ 2 files changed, 41 insertions(+) diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index a419140eb2..47fd745d2d 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -90,6 +90,9 @@ function_entry pgsql_functions[] = { PHP_FE(pg_options, NULL) PHP_FE(pg_version, NULL) PHP_FE(pg_ping, NULL) +#if HAVE_PQPARAMETERSTATUS + PHP_FE(pg_parameter_status, NULL) +#endif /* query functions */ PHP_FE(pg_query, NULL) PHP_FE(pg_send_query, NULL) @@ -928,6 +931,41 @@ PHP_FUNCTION(pg_version) } /* }}} */ +#if HAVE_PQPARAMETERSTATUS +/* {{{ proto string|false pg_parameter_status([resource connection,] string param_name) + Returns the value of a server parameter */ +PHP_FUNCTION(pg_parameter_status) +{ + zval *pgsql_link; + int id; + PGconn *pgsql; + char *param; + int len; + + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "rs", &pgsql_link, ¶m, &len) == SUCCESS) { + id = -1; + } else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", ¶m, &len) == SUCCESS) { + pgsql_link = NULL; + id = PGG(default_link); + } else { + RETURN_FALSE; + } + if (pgsql_link == NULL && id == -1) { + RETURN_FALSE; + } + + ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink); + + param = (char*)PQparameterStatus(pgsql, param); + if (param) { + RETURN_STRING(param, 1); + } else { + RETURN_FALSE; + } +} +/* }}} */ +#endif + /* {{{ proto bool pg_ping([resource connection]) Ping database. If connection is bad, try to reconnect. */ PHP_FUNCTION(pg_ping) diff --git a/ext/pgsql/php_pgsql.h b/ext/pgsql/php_pgsql.h index b9bdb483e9..80744ab185 100644 --- a/ext/pgsql/php_pgsql.h +++ b/ext/pgsql/php_pgsql.h @@ -73,6 +73,9 @@ PHP_FUNCTION(pg_tty); PHP_FUNCTION(pg_options); PHP_FUNCTION(pg_version); PHP_FUNCTION(pg_ping); +#if HAVE_PQPARAMETERSTATUS +PHP_FUNCTION(pg_parameter_status); +#endif /* query functions */ PHP_FUNCTION(pg_query); PHP_FUNCTION(pg_send_query); -- 2.40.0