diff --git a/core/cmdbsource.class.inc.php b/core/cmdbsource.class.inc.php index 48d67fcf4..be990a208 100644 --- a/core/cmdbsource.class.inc.php +++ b/core/cmdbsource.class.inc.php @@ -351,19 +351,21 @@ class CMDBSource } /** + * Get the version of the database server. + * * @return string * @throws \MySQLException * - * @uses \CMDBSource::QueryToCol() so needs a connection opened ! + * @uses \CMDBSource::QueryToScalar() so needs a connection opened ! */ public static function GetDBVersion() { - $aVersions = self::QueryToCol('SELECT Version() as version', 'version'); - return $aVersions[0]; + return static::QueryToScalar('SELECT VERSION()', 0); } /** - * @return string + * @deprecated Use `CMDBSource::GetDBVersion` instead. + * @uses mysqli_get_server_info */ public static function GetServerInfo() { @@ -1499,20 +1501,14 @@ class CMDBSource * Returns the value of the specified server variable * @param string $sVarName Name of the server variable * @return mixed Current value of the variable - */ + * @throws \MySQLQueryHasNoResultException|\MySQLException + */ public static function GetServerVariable($sVarName) { - $result = ''; - $sSql = "SELECT @@$sVarName as theVar"; - $aRows = self::QueryToArray($sSql); - if (count($aRows) > 0) - { - $result = $aRows[0]['theVar']; - } - return $result; + $sSql = 'SELECT @@'.$sVarName; + return static::QueryToScalar($sSql, 0) ?: ''; } - /** * Returns the privileges of the current user * @return string privileges in a raw format