diff --git a/core/database.php b/core/database.php index 4f6643a0..56639cf8 100644 --- a/core/database.php +++ b/core/database.php @@ -139,6 +139,11 @@ class Database return $this->engine->name; } + public function get_version(): string + { + return $this->engine->get_version($this->db); + } + private function count_time(string $method, float $start, string $query, ?array $args): void { global $_tracer, $tracer_enabled; diff --git a/core/dbengine.php b/core/dbengine.php index c974ab34..cb46ab4f 100644 --- a/core/dbengine.php +++ b/core/dbengine.php @@ -31,6 +31,8 @@ abstract class DBEngine } abstract public function set_timeout(PDO $db, int $time); + + abstract public function get_version(PDO $db): string; } class MySQL extends DBEngine @@ -68,12 +70,15 @@ class MySQL extends DBEngine // These only apply to read-only queries, which appears to be the best we can to mysql-wise // $db->exec("SET SESSION MAX_EXECUTION_TIME=".$time.";"); } + + public function get_version(PDO $db): string + { + return $db->query('select version()')->fetch()[0]; + } } class PostgreSQL extends DBEngine { - - /** @var string */ public $name = DatabaseDriver::PGSQL; @@ -110,6 +115,11 @@ class PostgreSQL extends DBEngine { $db->exec("SET statement_timeout TO ".$time.";"); } + + public function get_version(PDO $db): string + { + return $db->query('select version()')->fetch()[0]; + } } // shimmie functions for export to sqlite @@ -216,4 +226,9 @@ class SQLite extends DBEngine { // There doesn't seem to be such a thing for SQLite, so it does nothing } + + public function get_version(PDO $db): string + { + return $db->query('select sqlite_version()')->fetch()[0]; + } } diff --git a/ext/et/main.php b/ext/et/main.php index 2075f001..c7e3a3ad 100644 --- a/ext/et/main.php +++ b/ext/et/main.php @@ -69,7 +69,7 @@ class ET extends Extension 'shimmie' => VERSION, 'schema' => $config->get_int("db_version"), 'php' => phpversion(), - 'db' => $database->get_driver_name(), + 'db' => $database->get_driver_name() . " " . $database->get_version(), 'os' => php_uname(), 'server' => isset($_SERVER["SERVER_SOFTWARE"]) ? $_SERVER["SERVER_SOFTWARE"] : 'unknown', ],