W3cubDocs

/WordPress

wpdb::close(): bool

Closes the current database connection.

Return

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

Source

public function close() {
	if ( ! $this->dbh ) {
		return false;
	}

	$closed = mysqli_close( $this->dbh );

	if ( $closed ) {
		$this->dbh           = null;
		$this->ready         = false;
		$this->has_connected = false;
	}

	return $closed;
}

Changelog

Version Description
4.5.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wpdb/close