db = $db; $this->startedHere = !$this->db->getPdo()->inTransaction(); if ($this->startedHere) { $this->db->getPdo()->beginTransaction(); } } /** * Commit the transaction. */ public function commit(): void { if ($this->startedHere) { $this->db->getPdo()->commit(); } } /** * Roll the transaction back. */ public function rollback(): void { if ($this->startedHere) { $this->db->getPdo()->rollBack(); } } }