From 21d3a7198dc9d41810c5dc4e3cabe201ed6188e0 Mon Sep 17 00:00:00 2001 From: Tim van Dijen <tvdijen@gmail.com> Date: Tue, 7 Sep 2021 13:19:41 +0200 Subject: [PATCH] Add method to get the PDO driver --- lib/SimpleSAML/Database.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/SimpleSAML/Database.php b/lib/SimpleSAML/Database.php index ab5ddc2c7..8e267790e 100644 --- a/lib/SimpleSAML/Database.php +++ b/lib/SimpleSAML/Database.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SimpleSAML; +use Exception; use PDO; use PDOException; use PDOStatement; @@ -164,7 +165,7 @@ class Database return $db; } catch (PDOException $e) { - throw new \Exception("Database error: " . $e->getMessage()); + throw new Exception("Database error: " . $e->getMessage()); } } @@ -227,7 +228,7 @@ class Database return $query; } catch (PDOException $e) { $this->lastError = $db->errorInfo(); - throw new \Exception("Database error: " . $e->getMessage()); + throw new Exception("Database error: " . $e->getMessage()); } } @@ -247,7 +248,7 @@ class Database return $db->exec($stmt); } catch (PDOException $e) { $this->lastError = $db->errorInfo(); - throw new \Exception("Database error: " . $e->getMessage()); + throw new Exception("Database error: " . $e->getMessage()); } } @@ -291,4 +292,15 @@ class Database { return $this->lastError; } + + + /** + * Return the name of the PDO-driver + * + * @return string + */ + public function getDriver(): string + { + return $this->dbPrimary->getAttribute(PDO::ATTR_DRIVER_NAME); + } } -- GitLab