PHP 8.5.0 Alpha 1 available for testing

pg_version

(PHP 5, PHP 7, PHP 8)

pg_version Devuelve un array con las versiones del cliente, del protocolo y del servidor (si está disponible)

Descripción

pg_version(?PgSql\Connection $connection = null): array

pg_version() devuelve un array con las versiones del cliente, del protocolo y del servidor. Las versiones del protocolo y del servidor solo están disponibles si PHP ha sido compilado con PostgreSQL 7.4 o superior.

Para obtener más información sobre el servidor, utilice pg_parameter_status().

Parámetros

connection

An PgSql\Connection instance. When connection is null, the default connection is used. The default connection is the last connection made by pg_connect() or pg_pconnect().

Advertencia

As of PHP 8.1.0, using the default connection is deprecated.

Valores devueltos

Devuelve un array con las claves client, protocol y server y valores (si están disponibles).

Historial de cambios

Versión Descripción
8.1.0 The connection parameter expects an PgSql\Connection instance now; previously, a recurso was expected.
8.0.0 connection ahora es nullable.

Ejemplos

Ejemplo #1 Ejemplo con pg_version()

<?php
$dbconn
= pg_connect("host=localhost port=5432 dbname=marie")
or die(
"Conexión imposible");

$v = pg_version($dbconn);

echo
$v['client'];
?>

El resultado del ejemplo sería:

7.4

Ver también

add a note

User Contributed Notes 2 notes

up
0
live627
5 years ago
Complete output off this function for me is:

array(13) {
["client"]=>
string(5) "9.6.9"
["protocol"]=>
int(3)
["server"]=>
string(4) "12.1"
["server_encoding"]=>
string(4) "UTF8"
["client_encoding"]=>
string(4) "UTF8"
["is_superuser"]=>
string(2) "on"
["session_authorization"]=>
string(8) "postgres"
["DateStyle"]=>
string(8) "ISO, MDY"
["IntervalStyle"]=>
string(8) "postgres"
["TimeZone"]=>
string(10) "US/Arizona"
["integer_datetimes"]=>
string(2) "on"
["standard_conforming_strings"]=>
string(2) "on"
["application_name"]=>
string(0) ""
}
up
-1
mgchristensen
5 years ago
I note that the array element for "protocol" seemingly has no value, being reported as:

["protocol"]=> int(3)

whereas the array element for e.g. "server" is reported as (in my particular case):

["server"]=> string(5) "10.12"

A call to json_encode() however gives:

"protocol":3 and "server":"10.12"
To Top