From 414c05e67895d2f7d1ea192db32e7d04bfbe2bb8 Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Sun, 23 Jun 2013 20:02:05 +0000 Subject: [PATCH] functions.inc.php: - db_where_clause(): wrap condition in "(...)" model/PFAHandler.php: - read_from_db(): wrap condition in "(...)" git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1493 a1433add-5e2c-0410-b055-b7f2511e0802 --- functions.inc.php | 2 +- model/PFAHandler.php | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/functions.inc.php b/functions.inc.php index ee680a2e..052ea4b9 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -1651,7 +1651,7 @@ function db_where_clause($condition, $struct) { if (isset($struct[$field]) && $struct[$field]['type'] == 'bool') $value = db_get_boolean($value); $parts[] = "$field='" . escape_string($value) . "'"; } - $query = " WHERE " . join(" AND ", $parts) . " "; + $query = " WHERE ( " . join(" AND ", $parts) . " ) "; return $query; } diff --git a/model/PFAHandler.php b/model/PFAHandler.php index 635bda15..7532cb69 100644 --- a/model/PFAHandler.php +++ b/model/PFAHandler.php @@ -453,12 +453,10 @@ abstract class PFAHandler { $where = db_where_clause($condition, $this->struct); } else { if ($condition == "") $condition = '1=1'; - $where = " WHERE $condition "; + $where = " WHERE ( $condition ) "; } if ($this->domain_field != "") { - # TODO: wrap where clause in (...) to avoid problems if OR is used? - # TODO: Note: this would need a change in db_where_clause not to include the WHERE keyword in the result $where .= " AND " . db_in_clause($this->domain_field, $this->allowed_domains); }