}
if (\substr($this->getPackageVersion('com.woltlab.wcf'), 0, 3) == '1.1') {
- $sql = "SELECT MAX(attachmentID)
+ $sql = "SELECT COUNT(*)
FROM wcf" . $this->dbNo . "_attachment
WHERE packageID = ?
AND containerID > ?
AND containerType = ?";
} else {
- $sql = "SELECT MAX(attachmentID)
+ $sql = "SELECT COUNT(*)
FROM wcf" . $this->dbNo . "_attachment
WHERE packageID = ?
AND messageID > ?
$statement = $this->database->prepareStatement($sql);
$statement->execute([$packageID, 0, $type]);
- return $statement->fetchSingleColumn() ?: 0;
+ return $statement->fetchSingleColumn();
}
/**
WHERE packageID = ?
AND containerID > ?
AND containerType = ?
- AND attachmentID BETWEEN ? AND ?
ORDER BY attachmentID";
} else {
$sql = "SELECT *
WHERE packageID = ?
AND messageID > ?
AND messageType = ?
- AND attachmentID BETWEEN ? AND ?
ORDER BY attachmentID";
}
- $statement = $this->database->prepareStatement($sql, $limit);
- $statement->execute([$packageID, 0, $type, $offset + 1, $offset + $limit]);
+ $statement = $this->database->prepareStatement($sql, $limit, $offset);
+ $statement->execute([$packageID, 0, $type]);
while ($row = $statement->fetchArray()) {
$fileLocation = $this->fileSystemPath . 'attachments/attachment-' . $row['attachmentID'];