pg_parameter_status

(PHP 5, PHP 7, PHP 8)

pg_parameter_statusLooks up a current parameter setting of the server

Açıklama

pg_parameter_status(PgSql\Connection $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 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.

Dikkat

On a pre-7.4 PostgreSQL server, changing client_encoding via SET after connection startup will not be reflected by pg_parameter_status().

Bağımsız Değişkenler

connection

PgSql\Connection nesnesi. bağlantı belirtilmemişse öntanımlı bağlantı kullanılır. Öntanımlı bağlantı pg_connect() veya pg_pconnect() işleviyle kurulmuş son bağlantıdır.

Uyarı

PHP 8.1.0 ve sonrasında, öntanımlı bağlantının kullanımı önerilmemektedir.

param_name

Possible param_name values include server_version, server_encoding, client_encoding, is_superuser, session_authorization, DateStyle, TimeZone, and integer_datetimes. Note that this value is case-sensitive.

Dönen Değerler

A string containing the value of the parameter, false on failure or invalid param_name.

Sürüm Bilgisi

Sürüm: Açıklama
8.1.0 bağlantı bağımsız değişkeni artık PgSql\Connection nesnesi kabul ediyor, evvelce bir özkaynak kabul ederdi.

Örnekler

Örnek 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");
?>

Yukarıdaki örneğin çıktısı:

Server encoding: SQL_ASCII

add a note add a note

User Contributed Notes 2 notes

up
0
Ondej Bouda
8 years ago
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.
up
-2
Anonymous
5 years ago
pg_parameter_status() returns boolean FALSE for 'client', 'protocol' and 'server'.
Use pg_version() instead to get the software version numbers and the protocol.
To Top