You are here

public function Statement::execute in Drupal driver for SQL Server and SQL Azure 8.2

Same name in this branch
  1. 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/Statement.php \Drupal\Driver\Database\sqlsrv\Statement::execute()
  2. 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/PDO/Statement.php \Drupal\Driver\Database\sqlsrv\PDO\Statement::execute()

Execute a statement.

Parameters

array $args:

1 call to Statement::execute()
Statement::doExecute in drivers/lib/Drupal/Driver/Database/sqlsrv/Statement.php
1 method overrides Statement::execute()
Statement::execute in drivers/lib/Drupal/Driver/Database/sqlsrv/Statement.php
Execute a statement.

File

drivers/lib/Drupal/Driver/Database/sqlsrv/PDO/Statement.php, line 310

Class

Statement
Turbocharged Statement class to work with MSSQL server.

Namespace

Drupal\Driver\Database\sqlsrv\PDO

Code

public function execute($args = null) {
  $this->query_signature = md5($this->queryString);
  if ($this->cnn
    ->InDoomedTransaction()) {
    $this->cnn
      ->ThrowDoomedTransactionException();
  }
  $result = null;
  try {
    $count = 0;
    while (true) {
      try {
        $count++;
        $result = parent::execute($args);
        break;
      } catch (\PDOException $e) {

        // If the maximum retry limit is exceeded
        // throw the exception.
        if ($count > self::RETRY_MAX) {
          throw $e;
        }
        $safe = false;
        if ($this->options[Connection::PDO_RETRYONINTEGRITYVIOLATION] === true && in_array((string) $e
          ->getCode(), $this->INTEGRITY_VIOLATION_CONSTRAINT_CODES)) {
          $safe = true;
        }
        if ($this->options[Connection::PDO_RESILIENTRETRY] === true && in_array((string) $e
          ->getCode(), $this->CONNECTION_FAILED_CODES)) {
          $safe = true;
        }
        if (!$safe) {
          throw $e;
        }
        else {
          usleep($count * (1000000 * self::RETRY_DELAY));
        }
      }
    }
    if ($result == false) {
      $this->cnn
        ->ThrowPdoException($this, null);
    }
    return $result;
  } catch (\PDOException $e) {
    $this->cnn
      ->NotifyException($e);
    $this->cnn
      ->ThrowPdoException($this, $e);
    return null;
  }
}