pg_ping

Ping database connection

&reftitle.description; `bool` `pg_ping` ``PgSql\Connection``null```connection`&null;

`pg_ping` pings a database connection and tries to reconnect it if it is broken.

&reftitle.parameters;

`connection`

- &pgsql.parameter.connection-with-nullable-default;
&reftitle.returnvalues;

&return.success;

&reftitle.changelog;

&Version; | &Description;
&pgsql.changelog.connection-object;
8.0.0 | `connection` is now nullable.

&reftitle.examples;

### `pg_ping` example

    <?php
    $conn = pg_pconnect("dbname=publisher");
    if (!$conn) {
      echo "An error occurred.\n";
      exit;
    }

    if (!pg_ping($conn))
      die("Connection is broken\n");
    ?>

&reftitle.seealso;

- `pg_connection_status`
- `pg_connection_reset`