From edb78f936cb8a4f87d87776ebbcf2eddfd1fec74 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Thu, 5 Jun 2014 11:19:33 +0000 Subject: [PATCH] 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 --- dblayer.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dblayer.php b/dblayer.php index 7a01582..8851b68 100644 --- a/dblayer.php +++ b/dblayer.php @@ -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, "!=");