diff --git a/dblayer.php b/dblayer.php index 405a465..74279aa 100644 --- a/dblayer.php +++ b/dblayer.php @@ -102,18 +102,8 @@ class dblayer extends PDO switch ($driver[0]) { case "sqlite": - try - { - parent::__construct ($dsn, $username, $password, $driver_options); - parent::setAttribute (PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - } - catch (Exception $e) - { - throw new Exception ("PDO error : ".$e->getMessage(), 500); - } - // Look at the right to write in database and in the directory - $file = substr ($dsn, 7); + $file = substr ($dsn, 9); if (! is_writeable (dirname ($file))) throw new Exception (dgettext("domframework", "The directory for SQLite database is write protected"), @@ -125,6 +115,16 @@ class dblayer extends PDO if (function_exists ("posix_getuid") && fileowner ($file) === posix_getuid ()) chmod ($file, 0666); + try + { + parent::__construct ($dsn, $username, $password, $driver_options); + parent::setAttribute (PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + } + catch (Exception $e) + { + throw new Exception ("PDO error : ".$e->getMessage(), 500); + } + // Force ForeignKeys support (disabled by default) $this->exec("PRAGMA foreign_keys = ON"); $this->sep = "`";