openedTransaction++ ) { return $this->openTransaction(); } return $this->exec("SAVEPOINT transaction_{$this->openedTransaction}") !== false; } public function commit() : bool { if ( 0 === --$this->openedTransaction) { return parent::commit(); } return $this->exec("RELEASE SAVEPOINT transaction_{$this->openedTransaction}") !== false; } public function rollback() : bool { if ($this->openedTransaction > 1) { return $this->exec('ROLLBACK TO transaction_' . $this->openedTransaction--) !== false; } elseif ($this->openedTransaction-- === 1) { return parent::rollback(); } return false; } protected function openTransaction() : bool { return parent::beginTransaction(); } }