pg_close

(PHP 4, PHP 5, PHP 7, PHP 8)

pg_closeChiude una connessione PostgreSQL

Descrizione

pg_close(resource $connessione): bool

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.

add a note add a note

User Contributed Notes 2 notes

up
5
amays
18 years ago
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.
up
2
mark at redbrick dot dcu dot ie
20 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
To Top