@@ -90,6 +90,9 @@ function_entry pgsql_functions[] = {
9090 PHP_FE (pg_options , NULL )
9191 PHP_FE (pg_version , NULL )
9292 PHP_FE (pg_ping , NULL )
93+ #if HAVE_PQPARAMETERSTATUS
94+ PHP_FE (pg_parameter_status , NULL )
95+ #endif
9396 /* query functions */
9497 PHP_FE (pg_query , NULL )
9598 PHP_FE (pg_send_query , NULL )
@@ -928,6 +931,41 @@ PHP_FUNCTION(pg_version)
928931}
929932/* }}} */
930933
934+ #if HAVE_PQPARAMETERSTATUS
935+ /* {{{ proto string|false pg_parameter_status([resource connection,] string param_name)
936+ Returns the value of a server parameter */
937+ PHP_FUNCTION (pg_parameter_status )
938+ {
939+ zval * pgsql_link ;
940+ int id ;
941+ PGconn * pgsql ;
942+ char * param ;
943+ int len ;
944+
945+ if (zend_parse_parameters_ex (ZEND_PARSE_PARAMS_QUIET , ZEND_NUM_ARGS () TSRMLS_CC , "rs" , & pgsql_link , & param , & len ) == SUCCESS ) {
946+ id = -1 ;
947+ } else if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "s" , & param , & len ) == SUCCESS ) {
948+ pgsql_link = NULL ;
949+ id = PGG (default_link );
950+ } else {
951+ RETURN_FALSE ;
952+ }
953+ if (pgsql_link == NULL && id == -1 ) {
954+ RETURN_FALSE ;
955+ }
956+
957+ ZEND_FETCH_RESOURCE2 (pgsql , PGconn * , & pgsql_link , id , "PostgreSQL link" , le_link , le_plink );
958+
959+ param = (char * )PQparameterStatus (pgsql , param );
960+ if (param ) {
961+ RETURN_STRING (param , 1 );
962+ } else {
963+ RETURN_FALSE ;
964+ }
965+ }
966+ /* }}} */
967+ #endif
968+
931969/* {{{ proto bool pg_ping([resource connection])
932970 Ping database. If connection is bad, try to reconnect. */
933971PHP_FUNCTION (pg_ping )
0 commit comments