dblayer : add the connected tests before using the SQLITE PDO engine

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2051 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2015-03-23 09:49:49 +00:00
parent 839d71a44f
commit 5f441df4b7

View File

@@ -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 = "`";