当前位置: 首页>>代码示例>>PHP>>正文


PHP moodle_transaction::is_disposed方法代码示例

本文整理汇总了PHP中moodle_transaction::is_disposed方法的典型用法代码示例。如果您正苦于以下问题:PHP moodle_transaction::is_disposed方法的具体用法?PHP moodle_transaction::is_disposed怎么用?PHP moodle_transaction::is_disposed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在moodle_transaction的用法示例。


在下文中一共展示了moodle_transaction::is_disposed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: preventResetByRollback

 /**
  * Call this method from test if you want to make sure that
  * the resetting of database is done the slow way without transaction
  * rollback.
  *
  * This is useful especially when testing stuff that is not compatible with transactions.
  *
  * @return void
  */
 public function preventResetByRollback()
 {
     if ($this->testdbtransaction and !$this->testdbtransaction->is_disposed()) {
         $this->testdbtransaction->allow_commit();
         $this->testdbtransaction = null;
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:16,代码来源:advanced_testcase.php

示例2: rollback_delegated_transaction

 /**
  * Call when delegated transaction failed, this rolls back
  * all delegated transactions up to the top most level.
  *
  * In many cases you do not need to call this method manually,
  * because all open delegated transactions are rolled back
  * automatically if exceptions not caught.
  *
  * @param moodle_transaction $transaction An instance of a moodle_transaction.
  * @param Exception|Throwable $e The related exception/throwable to this transaction rollback.
  * @return void This does not return, instead the exception passed in will be rethrown.
  */
 public function rollback_delegated_transaction(moodle_transaction $transaction, $e)
 {
     if (!$e instanceof Exception && !$e instanceof Throwable) {
         // PHP7 - we catch Throwables in phpunit but can't use that as the type hint in PHP5.
         $e = new \coding_exception("Must be given an Exception or Throwable object!");
     }
     if ($transaction->is_disposed()) {
         throw new dml_transaction_exception('Transactions already disposed', $transaction);
     }
     // mark as disposed so that it can not be used again
     $transaction->dispose();
     // one rollback at any level rollbacks everything
     $this->force_rollback = true;
     if (empty($this->transactions) or $transaction !== $this->transactions[count($this->transactions) - 1]) {
         // this may or may not be a coding problem, better just rethrow the exception,
         // because we do not want to loose the original $e
         throw $e;
     }
     if (count($this->transactions) == 1) {
         // only rollback the top most level
         $this->rollback_transaction();
     }
     array_pop($this->transactions);
     if (empty($this->transactions)) {
         // finally top most level rolled back
         $this->force_rollback = false;
         \core\event\manager::database_transaction_rolledback();
         \core\message\manager::database_transaction_rolledback();
     }
     throw $e;
 }
开发者ID:gabrielrosset,项目名称:moodle,代码行数:43,代码来源:moodle_database.php

示例3: rollback_delegated_transaction

 /**
  * Call when delegated transaction failed, this rolls back
  * all delegated transactions up to the top most level.
  *
  * In many cases you do not need to call this method manually,
  * because all open delegated transactions are rolled back
  * automatically if exceptions not caught.
  *
  * @param moodle_transaction $transaction An instance of a moodle_transaction.
  * @param Exception $e The related exception to this transaction rollback.
  * @return void This does not return, instead the exception passed in will be rethrown.
  */
 public function rollback_delegated_transaction(moodle_transaction $transaction, Exception $e)
 {
     if ($transaction->is_disposed()) {
         throw new dml_transaction_exception('Transactions already disposed', $transaction);
     }
     // mark as disposed so that it can not be used again
     $transaction->dispose();
     // one rollback at any level rollbacks everything
     $this->force_rollback = true;
     if (empty($this->transactions) or $transaction !== $this->transactions[count($this->transactions) - 1]) {
         // this may or may not be a coding problem, better just rethrow the exception,
         // because we do not want to loose the original $e
         throw $e;
     }
     if (count($this->transactions) == 1) {
         // only rollback the top most level
         $this->rollback_transaction();
     }
     array_pop($this->transactions);
     if (empty($this->transactions)) {
         // finally top most level rolled back
         $this->force_rollback = false;
     }
     throw $e;
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:37,代码来源:moodle_database.php


注:本文中的moodle_transaction::is_disposed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。