Starts a transaction or sets a savepoint

@param string|null $savepoint savepoint name
@return $this
@throws exceptions\RuntimeException if trying to create a savepoint outside the transaction block
428856
public function beginTransaction(?string $savepoint = null): self
    {
        if (null === $savepoint) {
            if (!$this->inTransaction()) {
                $this->execute('BEGIN');
            }

        } elseif (!$this->inTransaction()) {
            throw new exceptions\RuntimeException(
                __METHOD__ . ': Savepoints can only be used in transaction blocks'
            );

        } else {
            $this->execute('SAVEPOINT ' . $savepoint);
        }

        return $this;
    }
443018
public function setClient($endpoint = null)
    {
        // Create client using API endpoint.
        $this->client = new Client([
                                       'base_uri' => ! is_null($endpoint) ? $endpoint : $this->endpoint,
                                   ]);

        return $this;
    }
497963
public function setEndPoint($endPoint)
    {
        if (strlen($this->getEndPointGroup()) > 0)
        {
            throw new RuntimeException(
                "End point group has been already set. You can set either end point or end point group."
            );
        }

        $this->endPoint = (int) $endPoint;

        return $this;
    }
423943
public function markFraud($timestamp = null)
  {
    if(empty($this->_customerFid))
    {
      throw new \RuntimeException(
        "You cannot mark a customer as fraud before setting a customer fid"
      );
    }

    $ep = $this->_getEndpoint();
    $this->_processRequest(
      $ep->markFraud(MarkDatePayload::create($this->_customerFid, $timestamp))
    );
    return $this;
  }
324001
function commit() {
		$this->savepoint--;

		if ($this->savepoint == 0) {
			if ( ! \mysqli_commit($this->dbh)) {
				throw new Panic('Failed to commit transaction');
			}
		}
		else { // not finished with transaction yet
			\mysqli_query($this->dbh, 'RELEASE SAVEPOINT save'.$this->savepoint);
		}

		return $this;
	}
1282523
public function transactionStart($asSavepoint = false)
	{
		$this->connect();

		if (!$asSavepoint || !$this->transactionDepth)
		{
			if ($this->setQuery('BEGIN TRANSACTION')->execute())
			{
				$this->transactionDepth = 1;
			}

			return;
		}

		$savepoint = 'SP_' . $this->transactionDepth;
		$this->setQuery('BEGIN TRANSACTION ' . $this->quoteName($savepoint));

		if ($this->execute())
		{
			$this->transactionDepth++;
		}
	}
981950
public function transactionStart($asSavepoint = false)
	{
		$this->connect();

		if (!$asSavepoint || !$this->transactionDepth)
		{
			$this->connection->beginTransaction();
		}

		$this->transactionDepth++;
	}
211695
public function setServiceEndpoint(string $endpoint): AbstractClientBuilder
    {
        if (!filter_var($endpoint, FILTER_VALIDATE_URL) || parse_url($endpoint, PHP_URL_SCHEME) !== 'https') {
            throw new \InvalidArgumentException('Incorrect endpoint given');
        }

        $this->endpoint = $endpoint;

        return $this;
    }
780662
def begin_transaction(self):
        """"""
        self.ensure_connected()
        self._transaction_nesting_level += 1
        if self._transaction_nesting_level == 1:
            self._driver.begin_transaction()
        elif self._nest_transactions_with_savepoints:
            self.create_savepoint(self._get_nested_transaction_savepoint_name())
26729
public function commit ()
    {
        $this->transaction_level--;

        if(!$this->nestable() || $this->transaction_level == 0) {
            parent::commit();
        } else {
            $this->exec("RELEASE SAVEPOINT LEVEL{$this->transaction_level}");

        }
    }
1147958
public function getRuntimeClient($versionEndpoint)
    {
        $versionMap = $this->_protocolClient->getVersionMap($versionEndpoint);

        foreach ($this->_supportedVersionList as $factory) {
            if (array_key_exists($factory->getVersion(), $versionMap)) {
                return $factory->createRuntimeClient(
                    $versionMap[$factory->getVersion()]
                );
            }
        }

        throw new \RuntimeException(Resources::INVALID_VERSION_MSG);
    }
789769
protected function savepointCreate(int $level)
    {
        $this->isProfiling() && $this->getLogger()->info("Transaction: new savepoint 'SVP{$level}'");
        $this->execute('SAVE TRANSACTION ' . $this->identifier("SVP{$level}"));
    }
317160
public function start()
    {
        if ($this->started) {
            throw new \RuntimeException('Cannot start nested transaction');
        }
        if (!$this->pdo->beginTransaction()) {
            throw new \RuntimeException('Failed to start transaction');
        }

        $this->started = true;
    }
1082532
public function commit()
    {
        if (!$this->getIsActive()) {
            throw new Exception('Failed to commit transaction: transaction was inactive.');
        }

        $this->_level--;
        if ($this->_level === 0) {
            Log::debug('Commit transaction' . __METHOD__);
            $this->db->pdo->commit();
            $this->db->trigger(Connection::EVENT_COMMIT_TRANSACTION);
            return;
        }

        $schema = $this->db->getSchema();
        if ($schema->supportsSavepoint()) {
            Log::debug('Release savepoint ' . $this->_level . __METHOD__);
            $schema->releaseSavepoint('LEVEL' . $this->_level);
        } else {
            Log::info('Transaction not committed: nested transaction not supported' . __METHOD__);
        }
    }
1312053
public function transactionRollback($toSavepoint = false)
	{
		$this->connect();

		if (!$toSavepoint || $this->transactionDepth === 1)
		{
			$this->connection->rollBack();
		}

		$this->transactionDepth--;
	}
1034156
public static void setSavePoint() {
        Connection connection = tl_conn.get();
        if (connection == null) {
            throw new RuntimeException("You do not start a Transaction so you can not set a savepoint!");
        }
        try {
            Stack<Savepoint> stack_sp = tl_sp.get();
            Savepoint sp = connection.setSavepoint();
            stack_sp.push(sp);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
622782
public function transactionCommit($toSavepoint = false)
	{
		if (!$toSavepoint || $this->transactionDepth <= 1)
		{
			$this->connect();

			if ($this->connection->commit())
			{
				$this->transactionDepth = 0;
			}

			return;
		}

		$this->transactionDepth--;
	}