wpdb::close()publicWP 4.5.0

Closes the current database connection.

Метод класса: wpdb{}

Хуков нет.

Возвращает

true|false. True if the connection was successfully closed, false if it wasn't, or if the connection doesn't exist.

Использование

global $wpdb;
$wpdb->close();

Список изменений

С версии 4.5.0 Введена.

Код wpdb::close() WP 6.5.2

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;
}