/** * @param \Closure $callback * @return mixed * @throws \Throwable */ public function transaction(Closure $callback) { if ($this->getDriverName() == 'sqlsrv') { return parent::transaction($callback); } $this->pdo->exec('BEGIN TRAN'); try { $result = $callback($this); $this->pdo->exec('COMMIT TRAN'); } catch (Exception $e) { $this->pdo->exec('ROLLBACK TRAN'); throw $e; } catch (Throwable $e) { $this->pdo->exec('ROLLBACK TRAN'); throw $e; } return $result; }