當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PDO::commit方法代碼示例

本文整理匯總了PHP中PDO::commit方法的典型用法代碼示例。如果您正苦於以下問題:PHP PDO::commit方法的具體用法?PHP PDO::commit怎麽用?PHP PDO::commit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PDO的用法示例。


在下文中一共展示了PDO::commit方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: runMigration

 /**
  * Выполняет запрос миграцию.
  * @param string $migrationName имя миграции
  * @param string $query запрос
  * @param string $type тип миграции
  * @return bool|\Exception|\PDOException
  * @throw \RuntimeException в случае, если не удалось применить
  */
 protected function runMigration($migrationName, $query, $type = 'up')
 {
     if (empty($query)) {
         throw new \RuntimeException('В миграции отсутствует запрос');
     }
     try {
         $this->db->beginTransaction();
         $statement = $this->db->prepare($query);
         $result = $statement->execute();
         if (!$result) {
             throw new \RuntimeException('Запрос не был выполнен');
         }
         $statement->closeCursor();
         if ($type == 'up') {
             $this->addMigrationInfo($migrationName);
         } else {
             $this->removeMigrationInfo($migrationName);
         }
         $this->db->commit();
     } catch (\PDOException $e) {
         $this->db->rollBack();
         throw $e;
     }
     return true;
 }
開發者ID:georgynet,項目名稱:migration,代碼行數:33,代碼來源:BaseMigrationCommand.php

示例2: commitTransaction

 public function commitTransaction()
 {
     if (!$this->pdo->inTransaction()) {
         throw new \RuntimeException('PDO is not in a transaction.');
     }
     $this->pdo->commit();
 }
開發者ID:rayrutjes,項目名稱:domain-foundation,代碼行數:7,代碼來源:PdoTransactionManager.php

示例3: commit

 public function commit()
 {
     if (--$this->transactionCounter === 0) {
         return $this->pdo->commit();
     }
     return $this->transactionCounter >= 0;
 }
開發者ID:bugadani,項目名稱:DBTiny,代碼行數:7,代碼來源:PDODriver.php

示例4: commit

 /**
  * {@inheritdoc}
  */
 public function commit()
 {
     $this->profiler->startQuery("COMMIT;");
     $result = $this->pdo->commit();
     $this->profiler->stopQuery();
     return $result;
 }
開發者ID:samleybrize,項目名稱:bugzorcist,代碼行數:10,代碼來源:PDOProfiler.php

示例5: _logCompletedJob

 private function _logCompletedJob(array $job)
 {
     $this->_pdo->beginTransaction();
     $this->_pdo->prepare("INSERT INTO {$this->_table_log} (id,app_id,metric,value,distinct_id,created_at,sent_at) VALUES(?,?,?,?,?,?,?)")->execute(array($job['id'], $job['app_id'], $job['metric'], $job['value'], $job['distinct_id'], $job['created_at'], date("Y-m-d H:i:s")));
     $this->_pdo->prepare("DELETE FROM {$this->_table_jobs} WHERE id = ? LIMIT 1")->execute(array($job['id']));
     $this->_pdo->commit();
 }
開發者ID:restful-labs,項目名稱:restful_metrics-php,代碼行數:7,代碼來源:JobRunner.php

示例6: commit

 public function commit()
 {
     if ($this->transactionsCount == 1) {
         $this->pdo->commit();
     }
     --$this->transactionsCount;
 }
開發者ID:artox-lab,項目名稱:fairy-database,代碼行數:7,代碼來源:Connection.php

示例7: endTransaction

 /**
  * Ends a transaction with the server.
  *
  * @param bool $commit
  * @return void
  */
 public function endTransaction($commit = false)
 {
     if ($commit) {
         $this->connection->commit();
     } else {
         $this->connection->rollBack();
     }
 }
開發者ID:rawebone,項目名稱:percy,代碼行數:14,代碼來源:MySqlAdapter.php

示例8: commit

 public function commit()
 {
     $this->transLevel--;
     if (!$this->transactionNestable() || $this->transLevel == 0) {
         $this->dbh->commit();
     } else {
         $this->dbh->exec(sprintf("RELEASE SAVEPOINT LEVEL%d", $this->transLevel));
     }
 }
開發者ID:hzh123,項目名稱:my_yaf,代碼行數:9,代碼來源:HaloPdo.php

示例9: close

 public function close()
 {
     if (isset($this->dbh)) {
         $options = $this->getOptions();
         if ($options['transaction']) {
             $this->dbh->commit();
         }
         unset($this->dbh);
     }
 }
開發者ID:beleneglorion,項目名稱:xtoy,代碼行數:10,代碼來源:PDOUpdater.php

示例10: run

 /**
  * @param string $script
  */
 public function run($script)
 {
     try {
         $this->pdo->beginTransaction();
         $this->pdo->query($script);
         $this->pdo->commit();
     } catch (\PDOException $e) {
         $this->pdo->rollBack();
     }
 }
開發者ID:belanur,項目名稱:docker-example,代碼行數:13,代碼來源:Migrator.php

示例11: commit

 /**
  * Valide la transaction ou bien libére le point de sauvegarde courant
  * @return bool
  */
 private function commit()
 {
     if (!--$this->transactionCounter) {
         return $this->pdolink->commit();
     }
     else{
         $this->pdolink->exec('RELEASE SAVEPOINT trans'.($this->transactionCounter + 1));
         return true;
     }
 }
開發者ID:RomLAURENT,項目名稱:Jar2Fer,代碼行數:14,代碼來源:bdd.php

示例12: transaction

 /**
  * @param \Closure $queries
  * @return bool
  */
 public function transaction(\Closure $queries)
 {
     $this->connection->beginTransaction();
     try {
         $queries($this);
         $this->connection->commit();
         return true;
     } catch (Exception $e) {
         $this->connection->rollback();
         return false;
     }
 }
開發者ID:fyuze,項目名稱:framework,代碼行數:16,代碼來源:Db.php

示例13: replaceTriplet

 /**
  * Replace current token after successful authentication
  * @param $credential
  * @param $token
  * @param $persistentToken
  * @param int $expire
  */
 public function replaceTriplet($credential, $token, $persistentToken, $expire = 0)
 {
     try {
         $this->connection->beginTransaction();
         $this->cleanTriplet($credential, $persistentToken);
         $this->storeTriplet($credential, $token, $persistentToken, $expire);
         $this->connection->commit();
     } catch (\PDOException $e) {
         $this->connection->rollBack();
         throw $e;
     }
 }
開發者ID:jeremycherfas,項目名稱:grav-blog,代碼行數:19,代碼來源:PDO.php

示例14: tearDown

 /**
  * This is run after each unit test. It empties the database.
  */
 protected function tearDown()
 {
     // Only commit if the transaction hasn't failed.
     // This is because tearDown() is also executed on a failed tests,
     // and we don't want to call ConnectionInterface::commit() in that case
     // since it will trigger an exception on its own
     // ('Cannot commit because a nested transaction was rolled back')
     if ($this->con->isCommitable()) {
         $this->con->commit();
     }
     $this->con = null;
 }
開發者ID:norfil,項目名稱:Propel2,代碼行數:15,代碼來源:BookstoreTestBase.php

示例15: create

 /**
  * @param $post
  * @return false|Post
  */
 public function create($post)
 {
     $sql = "INSERT INTO posts (user_id, message , created_at ,updated_at)  values (:user_id, :message, now(), now())";
     $stmt = $this->dbh->prepare($sql);
     $stmt->bindParam(':user_id', $post['user_id']);
     $stmt->bindParam(':message', $post['message']);
     $this->dbh->beginTransaction();
     $stmt->execute();
     $post = $this->findByID($this->dbh->lastInsertId());
     $this->dbh->commit();
     return $post;
 }
開發者ID:ogontaro,項目名稱:elites-output,代碼行數:16,代碼來源:post_mapper.php


注:本文中的PDO::commit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。