ENHANCEMENT Added PostgreSQLDatabaseConfigurationHelper::getDatabaseVersion()

This commit is contained in:
Sean Harvey 2010-05-26 05:14:05 +00:00
parent 2c38c37bb2
commit 133e6ff6ec

View File

@ -80,15 +80,8 @@ class PostgreSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelp
); );
} }
/** public function getDatabaseVersion($databaseConfig) {
* Ensure that the PostgreSQL version is at least 8.3. $version = 0;
* @param array $databaseConfig Associative array of db configuration, e.g. "server", "username" etc
* @return array Result - e.g. array('success' => true, 'error' => 'details of error')
*/
public function requireDatabaseVersion($databaseConfig) {
$success = false;
$error = '';
$username = $databaseConfig['username'] ? $databaseConfig['username'] : ''; $username = $databaseConfig['username'] ? $databaseConfig['username'] : '';
$password = $databaseConfig['password'] ? $databaseConfig['password'] : ''; $password = $databaseConfig['password'] ? $databaseConfig['password'] : '';
$server = $databaseConfig['server']; $server = $databaseConfig['server'];
@ -110,6 +103,19 @@ class PostgreSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelp
} }
} }
return $version;
}
/**
* Ensure that the PostgreSQL version is at least 8.3.
* @param array $databaseConfig Associative array of db configuration, e.g. "server", "username" etc
* @return array Result - e.g. array('success' => true, 'error' => 'details of error')
*/
public function requireDatabaseVersion($databaseConfig) {
$success = false;
$error = '';
$version = $this->getDatabaseVersion($databaseConfig);
if($version) { if($version) {
$success = version_compare($version, '8.3', '>='); $success = version_compare($version, '8.3', '>=');
if(!$success) { if(!$success) {