You are here

public function Connection::escapeField in Drupal driver for SQL Server and SQL Azure 8.2

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

Escapes a field name string.

Force all field names to be strictly alphanumeric-plus-underscore. For some database drivers, it may also wrap the field name in database-specific escape characters.

Parameters

string $field: An unsanitized field name.

Return value

string The sanitized field name.

Overrides Connection::escapeField

File

drivers/lib/Drupal/Driver/Database/sqlsrv/Connection.php, line 379
Definition of Drupal\Driver\Database\sqlsrv\Connection

Class

Connection
Temporary tables: temporary table support is done by means of global temporary tables (#) to avoid the use of DIRECT QUERIES. You can enable and disable the use of direct queries with $this->driver_settings->defaultDirectQuery =…

Namespace

Drupal\Driver\Database\sqlsrv

Code

public function escapeField($field) {
  if (!isset($this->escapedNames[$field])) {
    if (empty($field)) {
      $this->escapedNames[$field] = '';
    }
    else {
      $this->escapedNames[$field] = implode('.', array_map(array(
        $this,
        'quoteIdentifier',
      ), explode('.', preg_replace('/[^A-Za-z0-9_.]+/', '', $field))));
    }
  }
  return $this->escapedNames[$field];
}