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:
Ingo Schommer 2010-10-15 02:54:18 +00:00
parent db460ed57f
commit b839ab2b9f

View File

@ -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) { public function getDatabaseVersion($databaseConfig) {
$conn = @mysql_connect($databaseConfig['server'], null, null); $conn = @mysql_connect($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password']);
return @mysql_get_server_info($conn); 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;
} }
/** /**