downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

pg_connect> <pg_client_encoding
[edit] Last updated: Fri, 17 May 2013

view this page in

pg_close

(PHP 4, PHP 5)

pg_closeChiude 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.



pg_connect> <pg_client_encoding
[edit] Last updated: Fri, 17 May 2013
 
add a note add a note User Contributed Notes pg_close - [3 notes]
up
1
amays
7 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
0
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
up
-1
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.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites