Additional check for the presence of a database driver
This commit is contained in:
parent
88b5ab9fdb
commit
7962d485af
1 changed files with 5 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue