WP_Debug_Data::get_database_size()public staticWP 5.2.0

Fetches the total size of all the database tables for the active database user.

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

Хуков нет.

Возвращает

int. The size of the database, in bytes.

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

$result = WP_Debug_Data::get_database_size();

Заметки

  • Global. wpdb. $wpdb WordPress database abstraction object.

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

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

Код WP_Debug_Data::get_database_size() WP 6.5.2

public static function get_database_size() {
	global $wpdb;
	$size = 0;
	$rows = $wpdb->get_results( 'SHOW TABLE STATUS', ARRAY_A );

	if ( $wpdb->num_rows > 0 ) {
		foreach ( $rows as $row ) {
			$size += $row['Data_length'] + $row['Index_length'];
		}
	}

	return (int) $size;
}