Force Foreignkeys support in SQLite (PRAGMA foreign_keys = ON;)

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1422 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2014-06-05 11:19:33 +00:00
parent b7fe8ad341
commit edb78f936c

View File

@@ -85,6 +85,14 @@ class dblayer extends PDO
{
throw new Exception ("PDO error : ".$e->getMessage());
}
// Force specifics initialisations
switch ($this->db->getAttribute(PDO::ATTR_DRIVER_NAME))
{
case "sqlite":
// Force ForeignKeys support (disabled by default)
$this->db->exec("PRAGMA foreign_keys = ON");
}
}
/** Create a new entry in the table. Datas must be an indexed array
@@ -331,7 +339,9 @@ class dblayer extends PDO
}
else
{
if (!array_key_exists ($columns, $datasOK)) continue;
// FIXME ! Problem if $datasOK contains primary / else can be warned on
// $datasOK[$columns] if it doesn't exists
if (array_key_exists ($columns, $datasOK)) continue;
$select = array ();
if ($columns !== $this->primary)
$select[] = array ($this->primary, $updatekey, "!=");