public function deleteOption($key) { $stmt = $this->db->prepare("DELETE FROM options WHERE key IS :key"); $stmt->bindParam("key", $key, \PDO::PARAM_STR); $stmt->execute(); $this->db->commit(); }
/** * Commits the current transaction. * * @return void * @throws ConnectionException If the commit failed due to no active transaction or * because the transaction was marked for rollback only. */ public function commit() { if ($this->_transactionNestingLevel == 0) { throw ConnectionException::noActiveTransaction(); } if ($this->_isRollbackOnly) { throw ConnectionException::commitFailedRollbackOnly(); } $this->connect(); $logger = $this->_config->getSQLLogger(); if ($this->_transactionNestingLevel == 1) { if ($logger) { $logger->startQuery('"COMMIT"'); } $this->_conn->commit(); if ($logger) { $logger->stopQuery(); } } else { if ($this->_nestTransactionsWithSavepoints) { if ($logger) { $logger->startQuery('"RELEASE SAVEPOINT"'); } $this->releaseSavepoint($this->_getNestedTransactionSavePointName()); if ($logger) { $logger->stopQuery(); } } } --$this->_transactionNestingLevel; }
public function deleteVideo(Video $video) { $stmt = $this->db->prepare("DELETE FROM videos WHERE id IS :id"); $stmt->bindParam("id", $video->getId()); $stmt->execute(); $this->db->commit(); }
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; } }
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(); }
/** * Commits the current transaction. * * @return void * @throws ConnectionException If the commit failed due to no active transaction or * because the transaction was marked for rollback only. */ public function commit() { if ($this->_transactionNestingLevel == 0) { throw ConnectionException::noActiveTransaction(); } if ($this->_isRollbackOnly) { throw ConnectionException::commitFailedRollbackOnly(); } $this->connect(); if ($this->_transactionNestingLevel == 1) { $this->_conn->commit(); } --$this->_transactionNestingLevel; }
/** * Commits the current transaction. * * @return void * @throws ConnectionException If the commit failed due to no active transaction or * because the transaction was marked for rollback only. */ public function commit() { if ($this->_transactionNestingLevel == 0) { throw ConnectionException::noActiveTransaction(); } if ($this->_isRollbackOnly) { throw ConnectionException::commitFailedRollbackOnly(); } $this->connect(); if ($this->_transactionNestingLevel == 1) { $this->_conn->commit(); } else { if ($this->_nestTransactionsWithSavepoints) { $this->releaseSavepoint($this->_getNestedTransactionSavePointName()); } } --$this->_transactionNestingLevel; }
/** * {@inheritdoc} */ public function commit() { if (!$this->dbalConnection->commit()) { throw new CommitException('Cannot commit Doctrine DBAL transaction'); } }
function it_should_throw_an_exception_if_dbal_transaction_commit_failed(Connection $connection) { $connection->commit()->willReturn(false); $this->shouldThrow('\\RemiSan\\TransactionManager\\Exception\\CommitException')->duringCommit(); }