array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.pg-close.php', 1 => 'pg_close', ), 'up' => array ( 0 => 'ref.pgsql.php', 1 => 'PostgreSQL 函数', ), 'prev' => array ( 0 => 'function.pg-client-encoding.php', 1 => 'pg_client_encoding', ), 'next' => array ( 0 => 'function.pg-connect-poll.php', 1 => 'pg_connect_poll', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/pgsql/functions/pg-close.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
pg_close — 关闭 PostgreSQL 连接
pg_close() 关闭与指定 connection
实例关联的 PostgreSQL 数据库的非持久连接。
注意:
通常不需要使用 pg_close(),因为打开的非持久连接会在脚本结束时自动关闭。
connection
An PgSql\Connection instance.
When connection
is null
, the default connection is used.
The default connection is the last connection made by pg_connect()
or pg_pconnect().
As of PHP 8.1.0, using the default connection is deprecated.
总是返回 true
。
版本 | 说明 |
---|---|
8.2.0 |
现在返回类型为 true ;之前是 bool。
|
8.1.0 |
现在 connection 参数接受 PgSql\Connection
实例,之前接受 resource。
|
8.0.0 |
connection 现在可以为 null。
|
示例 #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