<?php
namespace wcf\system\stat;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\WCF;
/**
* @return integer
*/
protected function getCounter($date, $tableName, $dateColumnName) {
+ $conditionBuilder = new PreparedStatementConditionBuilder();
+ $conditionBuilder->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();
}
* @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();
}
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
+ }
}