function Connection::quoteIdentifiers

Same name in other branches
  1. 10 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::quoteIdentifiers()
  2. 11.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::quoteIdentifiers()

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 546

Class

Connection
Base Database API class.

Namespace

Drupal\Core\Database

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.