pg_ping
PHP function
Edit on GitHub ✎
(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)
Ping database connection
Description
pg_ping(PgSql\Connection|null $connection = null): bool
pg_ping() pings a database connection and tries to reconnect it if it is broken.
Parameters
connectionConnection-with-nullable-default
Return Values
Success
Changelog
| Version | Description |
|---|---|
| 8.0.0 | connection is now nullable. |
Examples
pg_ping() example
php
<?php
$conn = pg_pconnect("dbname=publisher");
if (!$conn) {
echo "An error occurred.\n";
exit;
}
if (!pg_ping($conn))
die("Connection is broken\n");
?>