DbTool: Add method getServerVersion()

refs #9460
This commit is contained in:
Johannes Meyer 2015-08-18 16:19:01 +02:00
parent 41ebb49c58
commit e7cfc25b04
1 changed files with 18 additions and 0 deletions

View File

@ -444,6 +444,24 @@ class DbTool
return $stmt;
}
/**
* Return the version of the server currently connected to
*
* @return string|null
*/
public function getServerVersion()
{
if ($this->config['db'] === 'mysql') {
return $this->query('show variables like "version"')->fetchColumn(1) ?: null;
} elseif ($this->config['db'] === 'pgsql') {
return $this->query('show server_version')->fetchColumn() ?: null;
} else {
throw new LogicException(
sprintf('Unable to fetch the server\'s version. Unsupported PDO driver "%s"', $this->config['db'])
);
}
}
/**
* Import the given SQL file
*