Rollback current transaction.

@param bool|null $toBeginning Whether or not the transaction should be rolled back to the
beginning of it. Defaults to false if using savepoints, or true if not.
@return bool
482436
public function rollback($toBeginning = null)
    {
        if (!$this->_transactionStarted) {
            return false;
        }

        $useSavePoint = $this->isSavePointsEnabled();
        if ($toBeginning === null) {
            $toBeginning = !$useSavePoint;
        }
        if ($this->_transactionLevel === 0 || $toBeginning) {
            $this->_transactionLevel = 0;
            $this->_transactionStarted = false;
            $this->nestedTransactionRollbackException = null;
            if ($this->_logQueries) {
                $this->log('ROLLBACK');
            }
            $this->_driver->rollbackTransaction();

            return true;
        }

        $savePoint = $this->_transactionLevel--;
        if ($useSavePoint) {
            $this->rollbackSavepoint($savePoint);
        } elseif ($this->nestedTransactionRollbackException === null) {
            $this->nestedTransactionRollbackException = new NestedTransactionRollbackException();
        }

        return true;
    }
1304136
final public function transRollback()
    {
        $this->logger->info('-- TRANSACTION ROLLBACK ');
        // reduce the transaction level
        if ($this->transactionLevel === 0) {
            trigger_error('Try to call rollback without a transaction', E_USER_NOTICE);
            return;
        }
        $this->transactionLevel = $this->transactionLevel - 1;
        // do rollback or savepoint
        if (0 === $this->transactionLevel) {
            $this->commandTransactionRollback();
        } else {
            $this->commandRollbackToSavepoint("LEVEL_{$this->transactionLevel}");
        }
    }
502514
protected function rollback()
    {
        $transaction = array_pop($this->_transaction);
        if ($transaction && $transaction instanceof Transaction) {
            $transaction->rollBack();
        }
    }
47476
public function rollBack($levels = null): bool
    {
        $this->__tRollBack($levels);
        if(null === $levels)
        {
            $this->__tRollBack($levels);
            $generator = $this->__rollBack($levels);
            if(!$generator->valid())
            {
                return $generator->getReturn();
            }
            $current = $generator->current();
            $generator->next();
            $generator->send($current);
            return $generator->getReturn();
        }
        else
        {
            $this->exec('ROLLBACK TO P' . $this->getTransactionLevels());
            return true;
        }
    }
69362
protected function rollback_transaction() {
        $this->savepointpresent = false;
        $sql = "RELEASE SAVEPOINT moodle_pg_savepoint; ROLLBACK";
        $this->query_start($sql, null, SQL_QUERY_AUX);
        $result = pg_query($this->pgsql, $sql);
        $this->query_end($result);

        pg_free_result($result);
    }
21585
protected boolean rollback()
    {
        if (currentOut != null) {
            currentOut.rollback();
            currentOut = null;
            moreOut = false;
        }
        return true;
    }
687436
public function transactionStart($transactionMode = false, $sessionCharacteristics = false)
    {
        if ($this->transactionNesting <= 0) {
            $this->transactionNesting = 1;
            $this->child->transactionStart($transactionMode, $sessionCharacteristics);
        } else {
            if ($this->child->supportsSavepoints()) {
                $this->child->transactionSavepoint("nesting" . $this->transactionNesting);
            }
            $this->transactionNesting++;
        }
    }
359637
public function doRevertToLive()
    {
        $owner = $this->owner;
        $owner->invokeWithExtensions('onBeforeRevertToLive');
        $owner->rollbackRecursive(static::LIVE);
        $owner->invokeWithExtensions('onAfterRevertToLive');
        return true;
    }
270785
public function rollback()
    {
        if (count($this->transactions) <= 1) {
            throw new UnbegunTransaction('Attempted to rollback without having begun a transaction.');
        }

        /** @var Transaction $transaction */
        $transaction = array_pop($this->transactions);

        return $transaction->rollback();
    }
541877
protected function _trans_rollback()
	{
		if (odbc_rollback($this->conn_id))
		{
			odbc_autocommit($this->conn_id, TRUE);
			return TRUE;
		}

		return FALSE;
	}
140320
private boolean rollbackIfNecessary(final Transactional transactional,
                                      final Exception e,
                                      final DefaultConnectionProvider conn) {
    boolean commit = true;

    //check rollback clauses
    for (Class<? extends Exception> rollBackOn : transactional.rollbackOn()) {

      //if one matched, try to perform a rollback
      if (rollBackOn.isInstance(e)) {
        commit = false;

        //check ignore clauses (supercedes rollback clause)
        for (Class<? extends Exception> exceptOn : transactional.ignore()) {
          //An exception to the rollback clause was found, DON'T rollback
          // (i.e. commit and throw anyway)
          if (exceptOn.isInstance(e)) {
            commit = true;
            break;
          }
        }

        //rollback only if nothing matched the ignore check
        if (!commit) {
          logger.debug("Rolling back JDBC transaction for this thread");
          conn.rollback();
        }
        //otherwise continue to commit

        break;
      }
    }

    return commit;
  }
950804
public function rollback()
    {
        if (!$this->started) {
            throw new \RuntimeException('Cannot rollback transaction before start');
        }
        if (!$this->pdo->rollBack()) {
            throw new \RuntimeException('Failed to rollback transaction');
        }

        $this->started = false;
    }
323831
public function rollBack($levels = null): bool
    {
        if(null === $levels)
        {
            $this->transactionLevels = 0;
        }
        else
        {
            $this->transactionLevels -= $levels;
        }
        return true;
    }
1077819
public function rollBack($toLevel = null)
    {
        // We allow developers to rollback to a certain transaction level. We will verify
        // that this given transaction level is valid before attempting to rollback to
        // that level. If it's not we will just return out and not attempt anything.
        $toLevel = is_null($toLevel)
                    ? $this->transactions - 1
                    : $toLevel;

        if ($toLevel < 0 || $toLevel >= $this->transactions) {
            return;
        }

        // Next, we will actually perform this rollback within this database and fire the
        // rollback event. We will also set the current transaction level to the given
        // level that was passed into this method so it will be right from here out.
        try {
            $this->performRollBack($toLevel);
        } catch (Exception $e) {
            $this->handleRollBackException($e);
        }

        $this->transactions = $toLevel;

        $this->fireConnectionEvent('rollingBack');
    }
1367127
private boolean rollbackIfNecessary(
      Transactional transactional, Exception e, EntityTransaction txn) {
    boolean commit = true;

    //check rollback clauses
    for (Class<? extends Exception> rollBackOn : transactional.rollbackOn()) {

      //if one matched, try to perform a rollback
      if (rollBackOn.isInstance(e)) {
        commit = false;

        //check ignore clauses (supercedes rollback clause)
        for (Class<? extends Exception> exceptOn : transactional.ignore()) {
          //An exception to the rollback clause was found, DON'T rollback
          // (i.e. commit and throw anyway)
          if (exceptOn.isInstance(e)) {
            commit = true;
            break;
          }
        }

        //rollback only if nothing matched the ignore check
        if (!commit) {
          txn.rollback();
        }
        //otherwise continue to commit

        break;
      }
    }

    return commit;
  }
1166453
public function rollBack() : bool
    {
        return $this->isConnected() && $this->getConnection()->inTransaction() && $this->getConnection()->rollBack();
    }
577941
public function commit()
    {
        $return = true;
        $opcount = $this->nestedTransactionCount;

        if ($opcount > 0) {
            if (1 === $opcount) {
                if ($this->isUncommitable) {
                    throw new RollbackException('Cannot commit because a nested transaction was rolled back');
                }

                $return = $this->connection->commit();
                if ($this->useDebug) {
                    $this->log('Commit transaction');
                }
            }

            $this->nestedTransactionCount--;
        }

        return $return;
    }