wpdb::close()

Closes the current database connection.


Description Description


Return Return

(bool) True if the connection was successfully closed, false if it wasn't, or the connection doesn't exist.


Top ↑

Source Source

File: wp-includes/wp-db.php

3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
public function close() {
    if ( ! $this->dbh ) {
        return false;
    }
 
    if ( $this->use_mysqli ) {
        $closed = mysqli_close( $this->dbh );
    } else {
        $closed = mysql_close( $this->dbh );
    }
 
    if ( $closed ) {
        $this->dbh           = null;
        $this->ready         = false;
        $this->has_connected = false;
    }
 
    return $closed;
}

Top ↑

Changelog Changelog

Changelog
Version Description
4.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.