mirror of
https://github.com/silverstripe/silverstripe-postgresql
synced 2024-10-22 15:05:45 +00:00
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:
parent
3b3258d3ae
commit
29f85e64cc
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user