From 675ecee53017f561ac9f1f447121a5e966204e4f Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Wed, 10 Sep 2014 11:13:57 +0000 Subject: [PATCH] dblayer : Add support to OR in WHERE clause git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1806 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- dblayer.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/dblayer.php b/dblayer.php index 9501355..daff43c 100644 --- a/dblayer.php +++ b/dblayer.php @@ -368,8 +368,11 @@ class dblayer extends PDO $display = array ($col1, $col2...); @param array|null $order Sort the columns by orientation $order = array (array ($key, $orientation), ...) - $key=>column, $orientation=ASC/DESC */ - public function read ($select=null, $display=null, $order=null) + $key=>column, $orientation=ASC/DESC + @param bool|null $whereOr The WHERE parameters are separated by OR instead + of AND*/ + public function read ($select=null, $display=null, $order=null, + $whereOr=false) { if ($this->db === null) throw new Exception (_("Database not connected"), 500); @@ -404,7 +407,12 @@ class dblayer extends PDO foreach ($select as $n=>$s) { if ($n > 0) - $req .= " AND"; + { + if ($whereOr === false) + $req .= " AND"; + else + $req .= " OR "; + } if (!isset ($s[2])) $s[2] = "="; $req .= " ".$s[0]." ".$s[2]." :".$s[0];