You are here

protected function Connection::quoteIdentifier in Drupal driver for SQL Server and SQL Azure 3.1.x

Quotes an identifier if it matches a SQL Server reserved keyword.

Parameters

string $identifier: The field to check.

Return value

string The identifier, quoted if it matches a SQL Server reserved keyword.

1 call to Connection::quoteIdentifier()
Connection::escapeField in src/Driver/Database/sqlsrv/Connection.php
Encapsulates field names in brackets when necessary.

File

src/Driver/Database/sqlsrv/Connection.php, line 960

Class

Connection
Sqlsvr implementation of \Drupal\Core\Database\Connection.

Namespace

Drupal\sqlsrv\Driver\Database\sqlsrv

Code

protected function quoteIdentifier($identifier) {
  if (strpos($identifier, '.') !== FALSE) {
    list($table, $identifier) = explode('.', $identifier, 2);
  }
  if (in_array(strtolower($identifier), $this->reservedKeyWords, TRUE)) {

    // Quote the string for SQLServer reserved keywords.
    $identifier = '[' . $identifier . ']';
  }
  return isset($table) ? $table . '.' . $identifier : $identifier;
}