dblayer : Add support to OR in WHERE clause
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1806 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
14
dblayer.php
14
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];
|
||||
|
||||
Reference in New Issue
Block a user