pg_parameter_status
(PHP 5, PHP 7, PHP 8)
pg_parameter_status — Looks up a current parameter setting of the server
Description
Looks up a current parameter setting of the server.
Certain parameter values are reported by the server automatically at connection startup or whenever their values change. pg_parameter_status() can be used to interrogate these settings. It returns the current value of a parameter if known, or false if the parameter is not known.
Parameters reported by the server include server_version, server_encoding, client_encoding, is_superuser, session_authorization, DateStyle, TimeZone, and integer_datetimes. Note that server_version, server_encoding and integer_datetimes cannot change after PostgreSQL startup.
Parameters
connectionAn PgSql\Connection instance. When
connectionis unspecified, the default connection is used. The default connection is the last connection made by pg_connect() or pg_pconnect().WarningAs of PHP 8.1.0, using the default connection is deprecated.
param_namePossible
param_namevalues includeserver_version,server_encoding,client_encoding,is_superuser,session_authorization,DateStyle,TimeZone, andinteger_datetimes. Note that this value is case-sensitive.
Return Values
A string containing the value of the parameter, false on failure or invalid param_name.
Changelog
| Version | Description |
|---|---|
| 8.1.0 | The connection parameter expects an PgSql\Connection instance now; previously, a resource was expected. |
Examples
Example #1 pg_parameter_status() example
<?php
$dbconn = pg_connect("dbname=publisher") or die("Could not connect");
echo "Server encoding: ", pg_parameter_status($dbconn, "server_encoding");
?>The above example will output:
Server encoding: SQL_ASCII