本文整理汇总了PHP中SC_Query_Ex::rollback方法的典型用法代码示例。如果您正苦于以下问题:PHP SC_Query_Ex::rollback方法的具体用法?PHP SC_Query_Ex::rollback怎么用?PHP SC_Query_Ex::rollback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SC_Query_Ex
的用法示例。
在下文中一共展示了SC_Query_Ex::rollback方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: revert
public function revert(array $migrations)
{
$migrations = $this->sort($migrations, SORT_DESC);
$reverteds = 0;
try {
foreach ($migrations as $migration) {
$this->query->begin();
if (!$this->storage->isAppliedVersion($migration->version)) {
$this->logger->log(sprintf('Revert migration skipped, Already reverted.: {system:"%s", version:"%s"}', $this->storage->system, $migration->version));
continue;
}
$migration->down();
$migration->applied = false;
$this->storage->markReverted($migration->version);
$this->query->commit();
$this->logger->log(sprintf('Revert migration successful: {system:"%s", version:"%s"}', $this->storage->system, $migration->version));
$reverteds++;
}
$this->query->commit();
} catch (Exception $e) {
if ($this->query->inTransaction()) {
$this->query->rollback();
}
$this->logger->log(sprintf('Revert migration failed: {system:"%s", version:"%s"}', $this->storage->system, $migration->version));
throw $e;
}
return $reverteds;
}