WP_Debug_Data::get_wp_database()
Gets the WordPress database section of the debug data.
Method of the class: WP_Debug_Data{}
No Hooks.
Return
Array
.
Usage
$result = WP_Debug_Data::get_wp_database(): array;
Notes
- Global. wpdb. $wpdb WordPress database abstraction object.
Changelog
Since 6.7.0 | Introduced. |
WP_Debug_Data::get_wp_database() WP Debug Data::get wp database code WP 6.8
private static function get_wp_database(): array { global $wpdb; // Populate the database debug fields. if ( is_object( $wpdb->dbh ) ) { // mysqli or PDO. $extension = get_class( $wpdb->dbh ); } else { // Unknown sql extension. $extension = null; } $server = $wpdb->get_var( 'SELECT VERSION()' ); $client_version = $wpdb->dbh->client_info; $fields = array( 'extension' => array( 'label' => __( 'Database Extension' ), 'value' => $extension, ), 'server_version' => array( 'label' => __( 'Server version' ), 'value' => $server, ), 'client_version' => array( 'label' => __( 'Client version' ), 'value' => $client_version, ), 'database_user' => array( 'label' => __( 'Database username' ), 'value' => $wpdb->dbuser, 'private' => true, ), 'database_host' => array( 'label' => __( 'Database host' ), 'value' => $wpdb->dbhost, 'private' => true, ), 'database_name' => array( 'label' => __( 'Database name' ), 'value' => $wpdb->dbname, 'private' => true, ), 'database_prefix' => array( 'label' => __( 'Table prefix' ), 'value' => $wpdb->prefix, 'private' => true, ), 'database_charset' => array( 'label' => __( 'Database charset' ), 'value' => $wpdb->charset, 'private' => true, ), 'database_collate' => array( 'label' => __( 'Database collation' ), 'value' => $wpdb->collate, 'private' => true, ), 'max_allowed_packet' => array( 'label' => __( 'Max allowed packet size' ), 'value' => self::get_mysql_var( 'max_allowed_packet' ), ), 'max_connections' => array( 'label' => __( 'Max connections number' ), 'value' => self::get_mysql_var( 'max_connections' ), ), ); return array( 'label' => __( 'Database' ), 'fields' => $fields, ); }