wc_get_server_database_version()WC 3.4.1

Retrieves the MySQL server version. Based on $wpdb.

No Hooks.

Return

Array. Vesion information.

Usage

wc_get_server_database_version();

Changelog

Since 3.4.1 Introduced.

wc_get_server_database_version() code WC 7.3.0

function wc_get_server_database_version() {
	global $wpdb;

	if ( empty( $wpdb->is_mysql ) || ! $wpdb->use_mysqli ) {
		return array(
			'string' => '',
			'number' => '',
		);
	}

	// phpcs:ignore WordPress.DB.RestrictedFunctions
	$server_info = mysqli_get_server_info( $wpdb->dbh );

	return array(
		'string' => $server_info,
		'number' => preg_replace( '/([^\d.]+).*/', '', $server_info ),
	);
}