You are here

public function Connection::quoteIdentifiers in Drupal 9

Quotes all identifiers in a query.

Queries sent to Drupal should wrap all unquoted identifiers in square brackets. This function searches for this syntax and replaces them with the database specific identifier. In ANSI SQL this a double quote.

Note that :variable[] is used to denote array arguments but Connection::expandArguments() is always called first.

@internal This method should only be called by database API code.

Parameters

string $sql: A string containing a partial or entire SQL query.

Return value

string The string containing a partial or entire SQL query with all identifiers quoted.

1 call to Connection::quoteIdentifiers()
Connection::preprocessStatement in core/lib/Drupal/Core/Database/Connection.php
Returns a string SQL statement ready for preparation.

File

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

Class

Connection
Base Database API class.

Namespace

Drupal\Core\Database

Code

public function quoteIdentifiers($sql) {
  return str_replace([
    '[',
    ']',
  ], $this->identifierQuotes, $sql);
}