The PostgreSQL PDO driver is built on top of the libpq client library. The driver allows you to transfer certain parameters of libpq connections to DSN in the form of key / value pairs, including TCP keepalives parameters.
From a PostgreSQL doc :
activity support
Controls the use of TCP client keepalives. The default value is 1, that is, the value, but you can change it to 0, which means "turn off" if keepalives are not needed. This parameter is ignored for connections made through a Unix domain socket.
keepalives_idle
, TCP keepalive . . , Unix- keepalives . , TCP_KEEPIDLE TCP_KEEPALIVE Windows; .
keepalives_interval
, TCP, , . . , Unix-, keepalives . , TCP_KEEPINTVL , Windows; .
:
<?
$db = new PDO('pgsql:dbname=mydb;host=localhost;user=myuser;password=mypass;keepalives_idle=60');
?>