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, 14 Aug 2009

view this page in

pg_close

(PHP 4, PHP 5)

pg_close Termine une connexion PostgreSQL

Description

bool pg_close ([ resource $connection ] )

pg_close() ferme la connexion au serveur PostgreSQL associé à connection .

Note: Il n'est généralement pas nécessaire de fermer une connexion non persistante, car elles sont automatiquement fermées à la fin d'un script.

Si des objets de grande taille ont été ouverts avec cette connexion, ne fermez pas la connexion avant d'avoir refermé les objets.

Liste de paramètres

connection

La ressource de connexion de la base de données PostgreSQL. Lorsque connection n'est pas présent, la connexion par défaut est utilisée. La connexion par défaut est la dernière connexion faite par pg_connect() ou pg_pconnect().

Valeurs de retour

Cette fonction retourne TRUE en cas de succès, FALSE en cas d'échec.

Exemples

Exemple #1 Exemple avec pg_close()

<?php
$dbconn 
pg_connect("host=localhost port=5432 dbname=marie")
      or die(
"Connexion impossible");
echo 
'Connexion réussie';
pg_close($dbconn);
?>

L'exemple ci-dessus va afficher :

Connexion réussie

Voir aussi



pg_connect> <pg_client_encoding
Last updated: Fri, 14 Aug 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, 14 Aug 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites