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

View File

@ -145,25 +145,14 @@ class PostgreSQLDatabase extends SS_Database {
return true; return true;
} }
/**
* The version of PostgreSQL.
* @var float
*/
private $pgsqlVersion;
/** /**
* Get the version of PostgreSQL. * Get the version of PostgreSQL.
* @return float * @return string
*/ */
public function getVersion() { public function getVersion() {
if(!$this->pgsqlVersion) { $version = pg_version($this->dbConn);
//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) if(isset($version['server'])) return $version['server'];
$postgres=strlen('PostgreSQL '); else return false;
$db_version=$this->query("SELECT VERSION()")->value();
$this->pgsqlVersion = (float)trim(substr($db_version, $postgres, strpos($db_version, ' on ')));
}
return $this->pgsqlVersion;
} }
/** /**