From: Matthias Schmidt Date: Sat, 5 Aug 2017 15:23:12 +0000 (+0200) Subject: Add `AbstractStatDailyHandler::addConditions()` X-Git-Tag: 3.1.0_Alpha_1~82 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2f13a7b14d49a3596c15335a907348f73abae294;p=GitHub%2FWoltLab%2FWCF.git Add `AbstractStatDailyHandler::addConditions()` Close #2365 --- diff --git a/wcfsetup/install/files/lib/system/stat/AbstractStatDailyHandler.class.php b/wcfsetup/install/files/lib/system/stat/AbstractStatDailyHandler.class.php index f9590710d0..7581ea66a2 100644 --- a/wcfsetup/install/files/lib/system/stat/AbstractStatDailyHandler.class.php +++ b/wcfsetup/install/files/lib/system/stat/AbstractStatDailyHandler.class.php @@ -1,5 +1,6 @@ add($dateColumnName . ' BETWEEN ? AND ?', [$date, $date + 86399]); + + $this->addConditions($conditionBuilder); + $sql = "SELECT COUNT(*) FROM " . $tableName . " - WHERE " . $dateColumnName . " BETWEEN ? AND ?"; + " . $conditionBuilder; $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute([$date, $date + 86399]); + $statement->execute($conditionBuilder->getParameters()); + return $statement->fetchColumn(); } @@ -37,11 +44,17 @@ abstract class AbstractStatDailyHandler implements IStatDailyHandler { * @return integer */ protected function getTotal($date, $tableName, $dateColumnName) { + $conditionBuilder = new PreparedStatementConditionBuilder(); + $conditionBuilder->add($dateColumnName . ' < ?', [$date + 86399]); + + $this->addConditions($conditionBuilder); + $sql = "SELECT COUNT(*) FROM " . $tableName . " - WHERE " . $dateColumnName . " < ?"; + " . $conditionBuilder; $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute([$date + 86400]); + $statement->execute($conditionBuilder->getParameters()); + return $statement->fetchColumn(); } @@ -51,4 +64,14 @@ abstract class AbstractStatDailyHandler implements IStatDailyHandler { public function getFormattedCounter($counter) { return $counter; } + + /** + * Adds additional conditions to the given condition builder. + * + * @param PreparedStatementConditionBuilder $conditionBuilder + * @since 3.1 + */ + protected function addConditions(PreparedStatementConditionBuilder $conditionBuilder) { + // does nothing + } }