You are here

public function Connection::prepareQuery in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::prepareQuery()

Prepares a query string and returns the prepared statement.

This method caches prepared statements, reusing them when possible. It also prefixes tables names enclosed in curly-braces and, optionally, quotes identifiers enclosed in square brackets.

Parameters

$query: The query string as SQL, with curly-braces surrounding the table names.

bool $quote_identifiers: (optional) Quote any identifiers enclosed in square brackets. Defaults to TRUE.

Return value

\Drupal\Core\Database\StatementInterface A PDO prepared statement ready for its execute() method.

Deprecated

in drupal:9.1.0 and is removed from drupal:10.0.0. Use ::prepareStatement instead.

See also

https://www.drupal.org/node/3137786

File

core/lib/Drupal/Core/Database/Connection.php, line 687

Class

Connection
Base Database API class.

Namespace

Drupal\Core\Database

Code

public function prepareQuery($query, $quote_identifiers = TRUE) {
  @trigger_error('Connection::prepareQuery() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use ::prepareStatement() instead. See https://www.drupal.org/node/3137786', E_USER_DEPRECATED);
  return $this
    ->prepareStatement($query, [
    'allow_square_brackets' => !$quote_identifiers,
  ]);
}