You are here

public function Connection::query 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/Connection.php \Drupal\Driver\Database\sqlsrv\Connection::query()
  2. 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/PDO/Connection.php \Drupal\Driver\Database\sqlsrv\PDO\Connection::query()

File

drivers/lib/Drupal/Driver/Database/sqlsrv/PDO/Connection.php, line 119

Class

Connection

Namespace

Drupal\Driver\Database\sqlsrv\PDO

Code

public function query($statement, $fetch_mode = null, $p1 = null, $p2 = null) {

  // By overriding this we are just making sure that we are able to INTERCEPT
  // any exception that might happen during a transaction.
  try {
    if (empty($fetch_mode)) {
      return parent::query($statement);
    }
    switch ($fetch_mode) {
      case PDO::FETCH_COLUMN:
        return parent::query($statement, $fetch_mode, $p1);
      case PDO::FETCH_CLASS:
        return parent::query($statement, $fetch_mode, $p1, $p2);
      case PDO::FETCH_INTO:
        return parent::query($statement, $fetch_mode, $p1, $p2);
      default:
        throw new \Exception("query() call not supported. Second argument needs to be one of PDO::FETCH_COLUMN | PDO::FETCH_CLASS | PDO::FETCH_INTO. Use query_execute() instead.");
    }
  } catch (\PDOException $e) {
    $this
      ->NotifyException($e);
    throw $e;
  }
}