mirror of
https://github.com/silverstripe/silverstripe-postgresql
synced 2024-10-22 17:05:45 +02: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;
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user