WP_Debug_Data::get_mysql_var()public staticWP 5.9.0

Returns the value of a MySQL system variable.

Method of the class: WP_Debug_Data{}

No Hooks.

Return

String|null. The variable value on success. Null if the variable does not exist.

Usage

$result = WP_Debug_Data::get_mysql_var( $mysql_var );
$mysql_var(string) (required)
Name of the MySQL system variable.

Notes

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

Changelog

Since 5.9.0 Introduced.

WP_Debug_Data::get_mysql_var() code WP 6.5.2

public static function get_mysql_var( $mysql_var ) {
	global $wpdb;

	$result = $wpdb->get_row(
		$wpdb->prepare( 'SHOW VARIABLES LIKE %s', $mysql_var ),
		ARRAY_A
	);

	if ( ! empty( $result ) && array_key_exists( 'Value', $result ) ) {
		return $result['Value'];
	}

	return null;
}