pg_close(...) will not technically close a persistent connection but instead returns it back to the connection pool thus giving you the desired effect of having the connection closed within your script.
http://www.sitepoint.com/article/accessing-postgresql-php/3
best wishes to all.
pg_close
(PHP 4, PHP 5)
pg_close — Chiude una connessione PostgreSQL
Descrizione
bool pg_close
( resource
$connessione
)
pg_close() chiude la connessione
non persistente verso un database PostgreSQL, identificata dalla risorsa
connessione. Restituisce TRUE in caso di successo, FALSE in caso di fallimento.
Nota:
iL'uso di pg_close() non è normalmente necessario, dal momento che le connessioni non persistenti vengono chiuse automaticamente alla fine dell'esecuzione dello script.
Se c'è una risorsa large object aperta sulla connessione, non chiudere quest'ultima finché la risorsa non è stata chiusa a sua volta.
amays ¶
7 years ago
mark at redbrick dot dcu dot ie ¶
10 years ago
This function closes the current database connection specified by a handle returned from a pg_connect() call.
<?php
$pgsql_conn = pg_connect("dbname=mark host=localhost");
if ($pgsql_conn) {
print "Successfully connected to: " . pg_host($pgsql_conn) . "<br/>\n";
} else {
print pg_last_error($pgsql_conn);
exit;
}
// Do database stuff here.
if(!pg_close($pgsql_conn)) {
print "Failed to close connection to " . pg_host($pgsql_conn) . ": " .
pg_last_error($pgsql_conn) . "<br/>\n";
} else {
print "Successfully disconnected from database";
}
?>
Of course you normally wouldn't print a message.
Regards, --mark
nox at macports dot org ¶
5 years ago
An E_WARNING level warning is generated if the supplied argument is not a valid postgresql link resource.
