pg_parameter_status()
(PHP 5, PHP 7)
Looks up a current parameter setting of the server
说明
pg_parameter_status([resource $connection],string $param_name): string
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 as of PostgreSQL 8.0 includeserver_version,server_encoding,client_encoding,is_superuser,session_authorization,DateStyle,TimeZone, andinteger_datetimes.(server_encoding,TimeZone, andinteger_datetimeswere not reported by releases before 8.0.)Note thatserver_version,server_encodingandinteger_datetimescannot change after PostgreSQL startup.
PostgreSQL 7.3 or lower servers do not report parameter settings,pg_parameter_status() includes logic to obtain values forserver_versionandclient_encodinganyway. Applications are encouraged to use pg_parameter_status() rather than ad hoc code to determine these values.
CautionOn a pre-7.4 PostgreSQL server, changingclient_encodingviaSETafter connection startup will not be reflected by pg_parameter_status().
参数
- $connection
PostgreSQL database connection resource. When$connectionis not present, the default connection is used. The default connection is the last connection made by pg_connect() or pg_pconnect().
- $param_name
Possible$param_namevalues includeserver_version,server_encoding,client_encoding,is_superuser,session_authorization,DateStyle,TimeZone, andinteger_datetimes.
返回值
A string containing the value of the parameter,FALSE
on failure or invalid$param_name.
范例
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"); ?>
以上例程会输出:
Server encoding: SQL_ASCII
Although PostgreSQL generally recognizes configuration parameters in a case-insensitive fashion (e.g., "SHOW datestyle" shows the "DateStyle" value), the pg_parameter_status() function is case sensitive.
pg_parameter_status() returns boolean FALSE for 'client', 'protocol' and 'server'. Use pg_version() instead to get the software version numbers and the protocol.