You are here

protected function Connection::replaceReservedCallback in Drupal driver for SQL Server and SQL Azure 3.0.x

Same name and namespace in other branches
  1. 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/Connection.php \Drupal\Driver\Database\sqlsrv\Connection::replaceReservedCallback()
  2. 8 drivers/lib/Drupal/Driver/Database/sqlsrv/Connection.php \Drupal\Driver\Database\sqlsrv\Connection::replaceReservedCallback()

Replace reserved words.

This method gets called between 3,000 and 10,000 times on cold caches. Make sure it is simple and fast.

Parameters

mixed $matches: What is this?

Return value

string The match surrounded with brackets.

File

drivers/lib/Drupal/Driver/Database/sqlsrv/Connection.php, line 982

Class

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

Namespace

Drupal\Driver\Database\sqlsrv

Code

protected function replaceReservedCallback($matches) {
  if ($matches[1] !== '') {

    // Replace reserved words. We are not calling
    // quoteIdentifier() on purpose.
    return '[' . $matches[1] . ']';
  }

  // Let other value passthru.
  // by the logic of the regex above, this will always be the last match.
  return end($matches);
}