php8.5
Home/ Manual/ pgsql / functions/ pg_connection_status

pg_connection_status

PHP function Edit on GitHub ✎

(PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8)

Get connection status

Description

pg_connection_status(PgSql\Connection $connection): int

pg_connection_status() returns the status of the specified connection.

Parameters

connection

Connection

Return Values

PGSQL_CONNECTION_OK or PGSQL_CONNECTION_BAD.

Changelog

VersionDescription

Examples

pg_connection_status() example

php
<?php
  $dbconn = pg_connect("dbname=publisher") or die("Could not connect");
  $stat = pg_connection_status($dbconn);
  if ($stat === PGSQL_CONNECTION_OK) {
      echo 'Connection status ok';
  } else {
      echo 'Connection status bad';
  }    
?>

See Also

Source: reference/pgsql/functions/pg-connection-status.xml · from the official PHP manual (php/doc-en)