From: Marcel Werk Date: Wed, 4 Jul 2012 16:49:09 +0000 (+0200) Subject: Added a function to disable the where keyword in condition builders X-Git-Tag: 2.0.0_Beta_1~1032^2~3 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=dc0034ff70ff8bd4759a4e287cd2b92a93ba7bdc;p=GitHub%2FWoltLab%2FWCF.git Added a function to disable the where keyword in condition builders --- 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