Exemple #1
0
 /**
  * Starts a transaction by suspending auto-commit mode.
  *
  * @return void
  */
 public function beginTransaction()
 {
     $this->connect();
     ++$this->_transactionNestingLevel;
     $logger = $this->_config->getSQLLogger();
     if ($this->_transactionNestingLevel == 1) {
         if ($logger) {
             $logger->startQuery('"START TRANSACTION"');
         }
         $this->_conn->beginTransaction();
         if ($logger) {
             $logger->stopQuery();
         }
     } else {
         if ($this->_nestTransactionsWithSavepoints) {
             if ($logger) {
                 $logger->startQuery('"SAVEPOINT"');
             }
             $this->createSavepoint($this->_getNestedTransactionSavePointName());
             if ($logger) {
                 $logger->stopQuery();
             }
         }
     }
 }
 protected function executeQueries(array $queries, \Closure $logger = null)
 {
     $this->conn->beginTransaction();
     try {
         foreach ($queries as $query) {
             if (null !== $logger) {
                 $logger($query);
             }
             $this->conn->query($query);
         }
         $this->conn->commit();
     } catch (\Exception $e) {
         $this->conn->rollback();
         throw $e;
     }
 }
Exemple #3
0
 /**
  * Starts a transaction by suspending auto-commit mode.
  *
  * @return void
  */
 public function beginTransaction()
 {
     $this->connect();
     if ($this->_transactionNestingLevel == 0) {
         $this->_conn->beginTransaction();
     }
     ++$this->_transactionNestingLevel;
 }
Exemple #4
0
 /**
  * Starts a transaction by suspending auto-commit mode.
  *
  * @return void
  */
 public function beginTransaction()
 {
     $this->connect();
     ++$this->_transactionNestingLevel;
     if ($this->_transactionNestingLevel == 1) {
         $this->_conn->beginTransaction();
     } else {
         if ($this->_nestTransactionsWithSavepoints) {
             $this->createSavepoint($this->_getNestedTransactionSavePointName());
         }
     }
 }
 public function migrate()
 {
     $this->initSchemaTable();
     $this->db->beginTransaction();
     $this->lockSchemaTable();
     foreach ($this->findMigrations($this->dir) as $migration) {
         $version = (int) $migration;
         if ($version <= $this->getCurrentVersion()) {
             continue;
         }
         $path = $this->dir . DIRECTORY_SEPARATOR . $migration;
         if (substr($path, -3) == 'php') {
             $db = $this->db;
             include_once $path;
         } else {
             $this->db->exec(file_get_contents($path));
         }
         $this->db->exec("UPDATE schema SET version = '{$version}'");
     }
     $this->db->commit();
 }
 /**
  * {@inheritdoc}
  */
 public function beginTransaction()
 {
     if (!$this->dbalConnection->beginTransaction()) {
         throw new BeginException('Cannot begin Doctrine DBAL transaction');
     }
 }
 function it_should_throw_an_exception_if_dbal_transaction_begin_failed(Connection $connection)
 {
     $connection->beginTransaction()->willReturn(false);
     $this->shouldThrow('\\RemiSan\\TransactionManager\\Exception\\BeginException')->duringBeginTransaction();
 }