WP_Debug_Data::get_mysql_var() WordPress Method

The get_mysql_var() method in the WP_Debug_Data class is used to get a MySQL server variable. The method takes a variable name as a parameter and returns the value of the variable.

WP_Debug_Data::get_mysql_var( string $mysql_var ) #

Returns the value of a MySQL system variable.


Parameters

$mysql_var

(string)(Required)Name of the MySQL system variable.


Top ↑

Return

(string|null) The variable value on success. Null if the variable does not exist.


Top ↑

Source

File: wp-admin/includes/class-wp-debug-data.php

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


Top ↑

Changelog

Changelog
VersionDescription
5.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.