添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Authentication Services
Command Line Specific Extensions
Compression and Archive Extensions
Cryptography Extensions
Database Extensions
Date and Time Related Extensions
File System Related Extensions
Human Language and Character Encoding Support
Image Processing and Generation
Mail Related Extensions
Mathematical Extensions
Non-Text MIME Output
Process Control Extensions
Other Basic Extensions
Other Services
Search Engine Extensions
Server Specific Extensions
Session Extensions
Text Processing
Variable and Type Related Extensions
Web Services
Windows Only Extensions
XML Manipulation
GUI Extensions
Keyboard Shortcuts
?
This help
Next menu item
Previous menu item
Previous man page
Next man page
Scroll to bottom
Scroll to top
Goto homepage
Goto search
(current page)
Focus search box

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.

示例 #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
mark at redbrick dot dcu dot ie
21 years ago
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