pg_parameter_status
(PHP 5, PHP 7, PHP 8)
pg_parameter_status — Looks up a current parameter setting of the server
说明
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 include server_version,
server_encoding, client_encoding,
is_superuser, session_authorization,
DateStyle, TimeZone, and integer_datetimes.
(server_encoding, TimeZone, and
integer_datetimes were not reported by releases before 8.0.) Note that
server_version, server_encoding and integer_datetimes
cannot change after PostgreSQL startup.
PostgreSQL 7.3 or lower servers do not report parameter settings,
pg_parameter_status()
includes logic to obtain values for server_version and
client_encoding
anyway. Applications are encouraged to use pg_parameter_status() rather than ad
hoc code to determine these values.
On a pre-7.4
PostgreSQL server, changing client_encoding via SET after connection startup will
not be reflected by pg_parameter_status().
参数
connection-
An 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().警告As of PHP 8.1.0, using the default connection is deprecated.
param_name-
Possible
param_namevalues includeserver_version,server_encoding,client_encoding,is_superuser,session_authorization,DateStyle,TimeZone, andinteger_datetimes. Note that this value is case-sensitive.
更新日志
| 版本 | 说明 |
|---|---|
| 8.1.0 |
现在 connection 参数接受 PgSql\Connection
实例,之前接受 resource。
|
示例
示例 #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
用户贡献的备注
备份地址:http://www.lvesu.com/blog/php/function.pg-parameter-status.php