From dc0034ff70ff8bd4759a4e287cd2b92a93ba7bdc Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Wed, 4 Jul 2012 18:49:09 +0200 Subject: [PATCH] Added a function to disable the where keyword in condition builders --- .../system/database/util/ConditionBuilder.class.php | 13 ++++++++++--- .../PreparedStatementConditionBuilder.class.php | 1 - 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/lib/system/database/util/ConditionBuilder.class.php b/wcfsetup/install/files/lib/system/database/util/ConditionBuilder.class.php index 8a833a1b3a..97ab6b2a38 100644 --- a/wcfsetup/install/files/lib/system/database/util/ConditionBuilder.class.php +++ b/wcfsetup/install/files/lib/system/database/util/ConditionBuilder.class.php @@ -43,8 +43,6 @@ class ConditionBuilder { foreach ($conditions as $condition) { if (!empty($this->conditions)) $this->conditions .= " AND "; - else $this->conditions = ($this->addWhereKeyword ? " WHERE " : ''); - $this->conditions .= $condition; } } @@ -55,6 +53,15 @@ class ConditionBuilder { * @return string */ public function __toString() { - return $this->conditions; + return (($this->addWhereKeyword && $this->conditions) ? 'WHERE ' : '').$this->conditions; + } + + /** + * Enables / disables the where keyword. + * + * @param boolean $enable + */ + public function enableWhereKeyword($enable = true) { + $this->addWhereKeyword = $enable; } } diff --git a/wcfsetup/install/files/lib/system/database/util/PreparedStatementConditionBuilder.class.php b/wcfsetup/install/files/lib/system/database/util/PreparedStatementConditionBuilder.class.php index 867ce2ec37..c66c6524f9 100644 --- a/wcfsetup/install/files/lib/system/database/util/PreparedStatementConditionBuilder.class.php +++ b/wcfsetup/install/files/lib/system/database/util/PreparedStatementConditionBuilder.class.php @@ -47,7 +47,6 @@ class PreparedStatementConditionBuilder extends ConditionBuilder { // add condtion if (!empty($this->conditions)) $this->conditions .= " AND "; - else $this->conditions = ($this->addWhereKeyword ? " WHERE " : ''); $this->conditions .= $condition; // parameter handling -- 2.20.1