mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX MySQLDatabaseConfigurationHelper::getVersion() will fallback to trying to get the version using a query if mysql_get_server_info() returns nothing (from r106071)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112512 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
db460ed57f
commit
b839ab2b9f
@ -42,9 +42,24 @@ class MySQLDatabaseConfigurationHelper implements DatabaseConfigurationHelper {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the database version for the MySQL connection, given the
|
||||
* database parameters.
|
||||
* @return mixed string Version number as string | boolean FALSE on failure
|
||||
*/
|
||||
public function getDatabaseVersion($databaseConfig) {
|
||||
$conn = @mysql_connect($databaseConfig['server'], null, null);
|
||||
return @mysql_get_server_info($conn);
|
||||
$conn = @mysql_connect($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password']);
|
||||
if(!$conn) return false;
|
||||
$version = @mysql_get_server_info($conn);
|
||||
if(!$version) {
|
||||
// fallback to trying a query
|
||||
$result = @mysql_query("SELECT VERSION()");
|
||||
$row = @mysql_fetch_array($result);
|
||||
if($row && isset($row[0])) {
|
||||
$version = trim($row[0]);
|
||||
}
|
||||
}
|
||||
return $version;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user