Closes a database connection

- « db2_client_info

- db2_column_privileges »

- PHP Manual
- IBM DB2 Functions
- Closes a database connection

# db2_close

(PECL ibm_db2 >= 1.0.0)

db2_close — Closes a database connection

### Description

db2_close(resource `$connection`): bool

This function closes a DB2 client connection created with db2_connect() and returns the corresponding resources to the database server.

If you attempt to close a persistent DB2 client connection created with db2_pconnect(), the close request is ignored and the persistent DB2 client connection remains available for the next caller.

### Parameters

`connection`

  Specifies an active DB2 client connection.

### Return Values

Returns `true` on success or `false` on failure.

### Examples

Example #1 Closing a connection

The following example demonstrates a successful attempt to close a connection to an IBM DB2, Cloudscape, or Apache Derby database.

    <?php$conn = db2_connect('SAMPLE', 'db2inst1', 'ibmdb2');$rc = db2_close($conn);if ($rc) {    echo "Connection was successfully closed.";}?>

The above example will output:

    Connection was successfully closed.

### See Also

- db2_connect() - Returns a connection to a database
- db2_pclose() - Closes a persistent database connection
- db2_pconnect() - Returns a persistent connection to a database