Forráskód Böngészése

Additional check for the presence of a database driver

Visman 5 éve
szülő
commit
7962d485af
1 módosított fájl, 5 hozzáadás és 1 törlés
  1. 5 1
      app/Core/DB.php

+ 5 - 1
app/Core/DB.php

@@ -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;