/** * Start a new database transaction. * * @return void */ public function beginTransaction() { ++$this->transactions; if ($this->transactions == 1) { $this->getPdo()->beginTransaction(); } elseif ($this->transactions > 1 && $this->queryGrammar->supportsSavepoints()) { $this->getPdo()->exec($this->queryGrammar->compileSavepoint('trans' . $this->transactions)); } $this->fireConnectionEvent('beganTransaction'); }
/** * Start a new database transaction. * * @return void * @throws Exception */ public function beginTransaction() { ++$this->transactions; if ($this->transactions == 1) { try { $this->pdo->beginTransaction(); } catch (Exception $e) { --$this->transactions; throw $e; } } elseif ($this->transactions > 1 && $this->queryGrammar->supportsSavepoints()) { $this->pdo->exec($this->queryGrammar->compileSavepoint('trans' . $this->transactions)); } $this->fireConnectionEvent('beganTransaction'); }
/** * Start a new database transaction. * * @return void * @throws Exception */ public function beginTransaction() { if ($this->transactions == 0) { try { $this->getPdo()->beginTransaction(); } catch (Exception $e) { if ($this->causedByLostConnection($e)) { $this->reconnect(); $this->pdo->beginTransaction(); } else { throw $e; } } } elseif ($this->transactions >= 1 && $this->queryGrammar->supportsSavepoints()) { $this->getPdo()->exec($this->queryGrammar->compileSavepoint('trans' . ($this->transactions + 1))); } ++$this->transactions; $this->fireConnectionEvent('beganTransaction'); }