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


PHP moodle_transaction::dispose方法代碼示例

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


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

示例1: 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

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