From 211dbfcefbf430c85d7103671961a68f26e27a01 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Fri, 13 Mar 2015 10:44:24 +0000 Subject: [PATCH] dblayer : don't allow the foreign keys to be in the select : conflict git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2022 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- dblayer.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dblayer.php b/dblayer.php index 50822b8..ed84872 100644 --- a/dblayer.php +++ b/dblayer.php @@ -635,6 +635,12 @@ class dblayer extends PDO $display = array_keys ($this->fields); } + $foreignSelectCols = array (); + if ($foreignSelect !== null) + { + foreach ($foreignSelect as $s) + $foreignSelectCols[] = $s[0]; + } $req = "SELECT $this->sep"; $req .= implode ("$this->sep,$this->sep", $display); $req .= "$this->sep "; @@ -648,6 +654,9 @@ class dblayer extends PDO // TODO Allow a field=>value in plus of array("field","value") foreach ($select as $n=>$s) { + // The foreign keys can not be in the select too (conflict) + if (in_array ($s[0],$foreignSelectCols)) + continue; if ($n > 0) { if ($whereOr === false)