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

search for in the

pg_connect> <pg_client_encoding
Last updated: Fri, 30 Oct 2009

view this page in

pg_close

(PHP 4, PHP 5)

pg_closeSchließt eine PostgreSQL-Verbindung

Beschreibung

bool pg_close ([ resource $connection ] )

pg_close() schließt die nicht-persistente Verbindung, die durch die Kennung connection bezeichnet wird.

Hinweis: Die Verwendung von pg_close() ist normalerweise nicht notwendig, da geöffnete, nicht-persistente Verbindungen automatisch geschlossen werden, wenn das Skript beendet wird.

Falls es auf dieser Verbindung geöffnete Large Objects gibt, sollten Sie diese schließen, bevor Sie die Verbindung schließen.

Parameter-Liste

connection

PostgreSQL-Verbindungkennung. Falls connection nicht angegeben wurde, wird die zuletzt mit pg_connect() oder pg_pconnect() geöffnete Verbindung benutzt.

Rückgabewerte

Gibt bei Erfolg TRUE zurück, im Fehlerfall FALSE.

Beispiele

Beispiel #1 pg_close()-Beispiel

<?php
$dbconn 
pg_connect("host=localhost port=5432 dbname=mary")
   or die(
"Keine Verbindung möglich");
echo 
"Verbindung hergestellt";
pg_close($dbconn);
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

Verbindung hergestellt

Siehe auch



pg_connect> <pg_client_encoding
Last updated: Fri, 30 Oct 2009
 
add a note add a note User Contributed Notes
pg_close
nox at macports dot org
27-Jul-2007 08:02
An E_WARNING level warning is generated if the supplied argument is not a valid postgresql link resource.
amays
15-Nov-2005 11:47
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.
mark at redbrick dot dcu dot ie
24-Mar-2003 02:31
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

pg_connect> <pg_client_encoding
Last updated: Fri, 30 Oct 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites