Additional check for the presence of a database driver

This commit is contained in:
Visman 2019-09-14 16:27:52 +07:00
parent 88b5ab9fdb
commit 7962d485af

View file

@ -59,7 +59,11 @@ class DB extends PDO
public function __construct($dsn, $username = null, $password = null, array $options = [], $prefix = '')
{
$type = \strstr($dsn, ':', true);
if (! $type || ! \is_file(__DIR__ . '/DB/' . \ucfirst($type) . '.php')) {
if (
! $type
|| ! \in_array($type, PDO::getAvailableDrivers())
|| ! \is_file(__DIR__ . '/DB/' . \ucfirst($type) . '.php')
) {
throw new PDOException("Driver isn't found for '$type'");
}
$this->dbType = $type;