doCommit example

protected function popCommittableTransactions() {
    // Commit all the committable layers.     foreach (array_reverse($this->transactionLayers) as $name => $active) {
      // Stop once we found an active transaction.       if ($active) {
        break;
      }

      // If there are no more layers left then we should commit.       unset($this->transactionLayers[$name]);
      if (empty($this->transactionLayers)) {
        $this->doCommit();
      }
      else {
        // Attempt to release this savepoint in the standard way.         try {
          $this->query('RELEASE SAVEPOINT ' . $name);
        }
        catch (DatabaseExceptionWrapper $e) {
          // However, in MySQL (InnoDB), savepoints are automatically committed           // when tables are altered or created (DDL transactions are not           // supported). This can cause exceptions due to trying to release           // savepoints which no longer exist.
protected function popCommittableTransactions() {
    // Commit all the committable layers.     foreach (array_reverse($this->transactionLayers) as $name => $active) {
      // Stop once we found an active transaction.       if ($active) {
        break;
      }

      // If there are no more layers left then we should commit.       unset($this->transactionLayers[$name]);
      if (empty($this->transactionLayers)) {
        $this->doCommit();
      }
      else {
        $this->query('RELEASE SAVEPOINT ' . $name);
      }
    }
  }

  /** * Do the actual commit, invoke post-commit callbacks. * * @internal */
Home | Imprint | This part of the site doesn't use cookies.