$sql = "DELETE FROM ".static::getDatabaseTableName()."
WHERE ".static::getDatabaseTableIndexName()." = ?";
$statement = WCF::getDB()->prepareStatement($sql);
+
+ WCF::getDB()->beginTransaction();
foreach ($objectIDs as $objectID) {
- $statement->execute(array($objectID));
+ $statement->executeUnbuffered(array($objectID));
}
+ WCF::getDB()->commitTransaction();
return count($objectIDs);
}
VALUES (?)";
$statement = self::getDB()->prepareStatement($sql);
+ self::getDB()->beginTransaction();
foreach ($acpTemplateInserts as $acpTemplate) {
- $statement->execute(array($acpTemplate));
+ $statement->executeUnbuffered(array($acpTemplate));
}
+ self::getDB()->commitTransaction();
}
// save file log
VALUES (?)";
$statement = self::getDB()->prepareStatement($sql);
+ self::getDB()->beginTransaction();
foreach ($fileInserts as $file) {
- $statement->execute(array($file));
+ $statement->executeUnbuffered(array($file));
}
+ self::getDB()->commitTransaction();
}
$this->gotoNextStep('installLanguage');
}
/**
- * Executes a prepared statement.
+ * Executes a prepared statement within a transaction.
*
* @param array $parameters
- * @return boolean true on success
*/
public function execute(array $parameters = array()) {
$this->database->incrementQueryCount();
+ $this->database->beginTransaction();
try {
if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->start($this->query, Benchmark::TYPE_SQL_QUERY);
- if (!count($parameters)) $result = $this->pdoStatement->execute();
- else $result = $this->pdoStatement->execute($parameters);
+ if (!count($parameters)) $this->pdoStatement->execute();
+ else $this->pdoStatement->execute($parameters);
if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->stop();
- return $result;
+ $this->database->commitTransaction();
+ }
+ catch (\PDOException $e) {
+ $this->database->rollBackTransaction();
+ throw new DatabaseException('Could not execute prepared statement: '.$e->getMessage(), $this->database, $this);
+ }
+ }
+
+ /**
+ * Executes a prepared statement.
+ *
+ * @param array $parameters
+ */
+ public function executeUnbuffered(array $parameters = array()) {
+ $this->database->incrementQueryCount();
+
+ try {
+ if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->start($this->query, Benchmark::TYPE_SQL_QUERY);
+
+ if (!count($parameters)) $this->pdoStatement->execute();
+ else $this->pdoStatement->execute($parameters);
+
+ if (WCF::benchmarkIsEnabled()) Benchmark::getInstance()->stop();
}
catch (\PDOException $e) {
throw new DatabaseException('Could not execute prepared statement: '.$e->getMessage(), $this->database, $this);