/** * Rollback the active database transaction. * * @return void */ public function rollBack() { if ($this->transactions == 1) { $this->getPdo()->rollBack(); } elseif ($this->transactions > 1 && $this->queryGrammar->supportsSavepoints()) { $this->getPdo()->exec($this->queryGrammar->compileSavepointRollBack('trans' . $this->transactions)); } $this->transactions = max(0, $this->transactions - 1); $this->fireConnectionEvent('rollingBack'); }
/** * Rollback the active database transaction. * * @param int|null $toLevel * @return void */ public function rollBack($toLevel = null) { if (is_null($toLevel)) { $toLevel = $this->transactions - 1; } if ($toLevel < 0 || $toLevel >= $this->transactions) { return; } if ($toLevel == 0) { $this->getPdo()->rollBack(); } elseif ($this->queryGrammar->supportsSavepoints()) { $this->getPdo()->exec($this->queryGrammar->compileSavepointRollBack('trans' . ($toLevel + 1))); } $this->transactions = $toLevel; $this->fireConnectionEvent('rollingBack'); }