pg_close
(PHP 4, PHP 5, PHP 7, PHP 8)
pg_close — 关闭 PostgreSQL 连接
说明
pg_close() 关闭与指定 connection
实例关联的 PostgreSQL 数据库的非持久连接。
注意:
通常不需要使用 pg_close(),因为打开的非持久连接会在脚本结束时自动关闭。
参数
connection-
An PgSql\Connection instance. When
connectionisnull, 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