当前位置: 首页>>代码示例>>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;未经允许,请勿转载。