public function Connection::queryDirect in Drupal driver for SQL Server and SQL Azure 3.0.x
Like query but with no query preprocessing.
The caller is sure that the query is MS SQL compatible! Used internally from the schema class, but could be called from anywhere.
Parameters
string $query: Query.
array $args: Query arguments.
mixed $options: Query options.
Return value
mixed Query result.
Throws
\PDOException
2 calls to Connection::queryDirect()
- Connection::nextId in drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Connection.php - Retrieves a unique ID from a given sequence.
- Connection::pushTransaction in drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Connection.php - Using SQL Server query syntax.
File
- drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Connection.php, line 861
Class
- Connection
- Sqlsvr implementation of \Drupal\Core\Database\Connection.
Namespace
Drupal\Driver\Database\sqlsrvCode
public function queryDirect($query, array $args = [], $options = []) {
// Use default values if not already set.
$options += $this
->defaultOptions();
$stmt = NULL;
try {
// Core tests run faster without emulating.
$direct_query_options = [
'direct_query' => TRUE,
'bypass_preprocess' => TRUE,
'emulate_prepares' => FALSE,
];
$stmt = $this
->prepareQuery($query, $direct_query_options + $options);
$stmt
->execute($args, $options);
// Depending on the type of query we may need to return a different value.
// See DatabaseConnection::defaultOptions() for a description of each
// value.
switch ($options['return']) {
case Database::RETURN_STATEMENT:
return $stmt;
case Database::RETURN_AFFECTED:
$stmt->allowRowCount = TRUE;
return $stmt
->rowCount();
case Database::RETURN_INSERT_ID:
return $this->connection
->lastInsertId();
case Database::RETURN_NULL:
return NULL;
default:
throw new \PDOException('Invalid return directive: ' . $options['return']);
}
} catch (\PDOException $e) {
// Most database drivers will return NULL here, but some of them
// (e.g. the SQLite driver) may need to re-run the query, so the return
// value will be the same as for static::query().
return $this
->handleQueryException($e, $query, $args, $options);
}
}