function Connection::query
Same name in this branch
- 9 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::query()
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Database/Driver/mysql/Connection.php \Drupal\Core\Database\Driver\mysql\Connection::query()
- 8.9.x core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php \Drupal\Core\Database\Driver\pgsql\Connection::query()
- 8.9.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::query()
- 10 core/modules/pgsql/src/Driver/Database/pgsql/Connection.php \Drupal\pgsql\Driver\Database\pgsql\Connection::query()
- 10 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::query()
- 11.x core/modules/pgsql/src/Driver/Database/pgsql/Connection.php \Drupal\pgsql\Driver\Database\pgsql\Connection::query()
- 11.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::query()
Overrides Connection::query
4 calls to Connection::query()
- Connection::hasJson in core/
modules/ pgsql/ src/ Driver/ Database/ pgsql/ Connection.php - Runs a simple query to validate json datatype support.
- Connection::nextId in core/
modules/ pgsql/ src/ Driver/ Database/ pgsql/ Connection.php - Retrieve a the next id in a sequence.
- Connection::queryRange in core/
modules/ pgsql/ src/ Driver/ Database/ pgsql/ Connection.php - Runs a limited-range query on this database object.
- Connection::queryTemporary in core/
modules/ pgsql/ src/ Driver/ Database/ pgsql/ Connection.php - Runs a SELECT query and stores its results in a temporary table.
File
-
core/
modules/ pgsql/ src/ Driver/ Database/ pgsql/ Connection.php, line 155
Class
- Connection
- PostgreSQL implementation of \Drupal\Core\Database\Connection.
Namespace
Drupal\pgsql\Driver\Database\pgsqlCode
public function query($query, array $args = [], $options = []) {
$options += $this->defaultOptions();
// The PDO PostgreSQL driver has a bug which doesn't type cast booleans
// correctly when parameters are bound using associative arrays.
// @see http://bugs.php.net/bug.php?id=48383
foreach ($args as &$value) {
if (is_bool($value)) {
$value = (int) $value;
}
}
// We need to wrap queries with a savepoint if:
// - Currently in a transaction.
// - A 'mimic_implicit_commit' does not exist already.
// - The query is not a savepoint query.
$wrap_with_savepoint = $this->inTransaction() && !isset($this->transactionLayers['mimic_implicit_commit']) && !(is_string($query) && (stripos($query, 'ROLLBACK TO SAVEPOINT ') === 0 || stripos($query, 'RELEASE SAVEPOINT ') === 0 || stripos($query, 'SAVEPOINT ') === 0));
if ($wrap_with_savepoint) {
// Create a savepoint so we can rollback a failed query. This is so we can
// mimic MySQL and SQLite transactions which don't fail if a single query
// fails. This is important for tables that are created on demand. For
// example, \Drupal\Core\Cache\DatabaseBackend.
$this->addSavepoint();
try {
$return = parent::query($query, $args, $options);
$this->releaseSavepoint();
} catch (\Exception $e) {
$this->rollbackSavepoint();
throw $e;
}
}
else {
$return = parent::query($query, $args, $options);
}
return $return;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.