public function Connection::queryDirect in Drupal driver for SQL Server and SQL Azure 4.2.x
Same name and namespace in other branches
- 3.1.x src/Driver/Database/sqlsrv/Connection.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Connection::queryDirect()
- 4.0.x src/Driver/Database/sqlsrv/Connection.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Connection::queryDirect()
- 4.1.x src/Driver/Database/sqlsrv/Connection.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Connection::queryDirect()
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
3 calls to Connection::queryDirect()
- Connection::nextId in src/
Driver/ Database/ sqlsrv/ Connection.php - Retrieves a unique ID from a given sequence.
- Connection::pushTransaction in src/
Driver/ Database/ sqlsrv/ Connection.php - Using SQL Server query syntax.
- Connection::rollBack in src/
Driver/ Database/ sqlsrv/ Connection.php - Using SQL Server query syntax.
File
- src/
Driver/ Database/ sqlsrv/ Connection.php, line 789
Class
- Connection
- Sqlsvr implementation of \Drupal\Core\Database\Connection.
Namespace
Drupal\sqlsrv\Driver\Database\sqlsrvCode
public function queryDirect($query, array $args = [], $options = []) {
// Use default values if not already set.
$options += $this
->defaultOptions();
// Core tests run faster without emulating.
$direct_query_options = [
'direct_query' => TRUE,
'bypass_preprocess' => TRUE,
'emulate_prepares' => FALSE,
];
$stmt = $this
->prepareStatement($query, $direct_query_options + $options);
try {
$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 (\Exception $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
->exceptionHandler()
->handleExecutionException($e, $stmt, $args, $options);
}
}