You are here

public function DatabaseConnection_sqlsrv::handleQueryException in Drupal driver for SQL Server and SQL Azure 7.3

Same name and namespace in other branches
  1. 7.2 sqlsrv/database.inc \DatabaseConnection_sqlsrv::handleQueryException()

Wraps and re-throws any PDO exception thrown by static::query().

Parameters

\PDOException $e: The exception thrown by static::query().

$query: The query executed by static::query().

array $args: An array of arguments for the prepared statement.

array $options: An associative array of options to control how the query is run.

Return value

DatabaseStatementInterface|int|null Most database drivers will return NULL when a PDO exception is thrown for a query, but some of them may need to re-run the query, so they can also return a \Drupal\Core\Database\StatementInterface object or an integer.

2 calls to DatabaseConnection_sqlsrv::handleQueryException()
DatabaseConnection_sqlsrv::query in sqlsrv/database.inc
This method is overriden to manage the insecure (EMULATE_PREPARE) behaviour to prevent some compatibility issues with SQL Server.
DatabaseConnection_sqlsrv::query_direct in sqlsrv/database.inc
Like query but with no insecure detection or query preprocessing. The caller is sure that his query is MS SQL compatible! Used internally from the schema class, but could be called from anywhere.

File

sqlsrv/database.inc, line 573
Database interface code for Microsoft SQL Server.

Class

DatabaseConnection_sqlsrv
Summary of DatabaseConnection_sqlsrv

Code

public function handleQueryException(\PDOException $e, $query, array $args = array(), $options = array()) {
  if ($options['throw_exception']) {

    // Add additional debug information.
    if ($query instanceof DatabaseStatement_sqlsrv) {

      /** @var DatabaseStatement_sqlsrv $statement */
      $statement = $query;
      $e->query_string = $statement
        ->getQueryString();
      $e->args = $statement
        ->GetBoundParameters();
    }
    else {
      $e->query_string = $query;
    }
    if (empty($e->args)) {
      $e->args = $args;
    }
    throw $e;
  }
  return NULL;
}