From 0df7e1bdedf3dd95774f317609ec8fcf2d7b563e Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Wed, 3 May 2017 08:02:06 +0000 Subject: [PATCH] dblayeroo: allow the primary key to be the unique key (and the unique is not defined) git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3564 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- dblayeroo.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dblayeroo.php b/dblayeroo.php index e929a29..27069f3 100644 --- a/dblayeroo.php +++ b/dblayeroo.php @@ -2184,10 +2184,11 @@ class dblayeroo // - Check the unique entries (if defined) // The primary key is always unique : add it if not set by the user $this->debugLog (" verify the unique constraint"); - if (! in_array ($this->primary, $this->unique)) - $uniques = array_merge (array ($this->primary), $this->unique); - else - $uniques = $this->unique; + $uniques = $this->unique; + if (! is_array ($uniques)) + $uniques = array (); + if (! in_array ($this->primary, $uniques)) + $uniques = array_merge (array ($this->primary), $uniques); $setValues = $values; if (! array_key_exists ($this->primary, $setValues)) $setValues[$this->primary] = null;