diff --git a/dblayer.php b/dblayer.php index 8851b68..372e55f 100644 --- a/dblayer.php +++ b/dblayer.php @@ -67,6 +67,11 @@ class dblayer extends PDO SQLite3 : PRAGMA TABLE_INFO('yourtable'); MYSQL : SHOW COLUMNS FROM yourtable;*/ + // TODO !! + /** Allow to modify tables if the definition is changed + Attention : SQLite don't supports adding Foreign keys without deleting all + the table, and re-import the datas (http://www.sqlite.org/omitted.html) */ + /** Connection to the database engine See http://fr2.php.net/manual/en/pdo.construct.php for the $dsn format @param string $dsn PDO Data Source Name @@ -90,8 +95,18 @@ class dblayer extends PDO switch ($this->db->getAttribute(PDO::ATTR_DRIVER_NAME)) { case "sqlite": + // Look at the right to write in database and in the directory + $file = substr ($dsn, 7); + if (! is_writeable (dirname ($file))) + throw new Exception ( + _("The directory for SQLite database is write protected"), + 500); + if (file_exists ($file) && ! is_writeable ($file)) + throw new Exception (_("The SQLite database file is write protected"), + 500); // Force ForeignKeys support (disabled by default) $this->db->exec("PRAGMA foreign_keys = ON"); + break; } }