Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: pg_close - Manual
[go: Go Back, main page]

PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<pg_client_encodingpg_connect" width="11" height="7"/>
view the version of this page
Last updated: Sun, 07 May 2006

pg_close

(PHP 3, PHP 4, PHP 5)

pg_close -- PostgreSQL 接続をクローズする

説明

bool pg_close ( [resource connection] )

pg_close() は、 connection リソースで指定した PostgreSQL データベースへの持続的でない接続を閉じます。

注意: 持続的でない接続はスクリプトの実行終了時に自動的にクローズされるため、 pg_close() は通常は必要ありません。

接続の中でラージオブジェクトをオープンしている場合は、すべての ラージオブジェクトリソースをクローズするまで接続を閉じないでください。

パラメータ

connection

PostgreSQL データベース接続リソース。connection が指定されていない場合はデフォルトの接続が使用されます。 デフォルトの接続は、直近の pg_connect() あるいは pg_pconnect() によって作成されたものです。

返り値

成功した場合に TRUE を、失敗した場合に FALSE を返します。

例 1. pg_close() の例

<?php
$dbconn
= pg_connect("host=localhost port=5432 dbname=mary")
   or die(
"Could not connect");
echo
"Connected successfully";
pg_close($dbconn);
?>

上の例の出力は以下となります。

Connected successfully

参考

pg_connect()



add a note add a note User Contributed Notes
pg_close
amays
16-Nov-2005 08: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 11: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_client_encodingpg_connect" width="11" height="7"/>
 Last updated: Sun, 07 May 2006
show source | credits | sitemap | contact | advertising | mirror sites 
Copyright © 2001-2006 The PHP Group
All rights reserved.
This mirror generously provided by: PacketBusiness, Inc.
Last updated: Wed Jun 28 13:19:26 2006 JST