ENHANCEMENT PostgreSQLDatabase::getVersion() uses pg_version() to get the server version number, which is more reliable than parsing a version string

This commit is contained in:
Sean Harvey 2010-10-13 22:30:52 +00:00
parent 3b3258d3ae
commit 29f85e64cc
1 changed files with 4 additions and 15 deletions

View File

@ -145,25 +145,14 @@ class PostgreSQLDatabase extends SS_Database {
return true;
}
/**
* The version of PostgreSQL.
* @var float
*/
private $pgsqlVersion;
/**
* Get the version of PostgreSQL.
* @return float
* @return string
*/
public function getVersion() {
if(!$this->pgsqlVersion) {
//returns something like this: PostgreSQL 8.3.3 on i386-apple-darwin9.3.0, compiled by GCC i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5465)
$postgres=strlen('PostgreSQL ');
$db_version=$this->query("SELECT VERSION()")->value();
$this->pgsqlVersion = (float)trim(substr($db_version, $postgres, strpos($db_version, ' on ')));
}
return $this->pgsqlVersion;
$version = pg_version($this->dbConn);
if(isset($version['server'])) return $version['server'];
else return false;
}
/**