Skip to content
Snippets Groups Projects
Commit 21d3a719 authored by Tim van Dijen's avatar Tim van Dijen
Browse files

Add method to get the PDO driver

parent 83f1c58b
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment