From 1cfc21e5f073a877a9ac61b74b5ff4d68b53e0b7 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Mon, 23 Mar 2015 11:08:28 +0000 Subject: [PATCH] dblayer : check if the unique key is defined before using it in UPDATE. If not defined, use primary key git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2052 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- dblayer.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dblayer.php b/dblayer.php index 74279aa..f7f9073 100644 --- a/dblayer.php +++ b/dblayer.php @@ -378,8 +378,14 @@ class dblayer extends PDO { if ($this->debug) echo " verify NO updatekey\n"; $after = $datasOK; + } // Check if the unique constrain is valid before doing the insertion + if ($this->unique === null && $this->primary !== null) + $this->unique = array ($this->primary); + // TODO : If Unique is not defined nor primary + // FIXME : If unique is defined, could I test if the primary key is defined + // in a parameter of the unique and if it is not add it automatically foreach ($this->unique as $k=>$columns) { if ($this->primary === null)