You are here

public function DatabaseConnection_sqlsrv::escapeField in Drupal driver for SQL Server and SQL Azure 7.2

Same name and namespace in other branches
  1. 7.3 sqlsrv/database.inc \DatabaseConnection_sqlsrv::escapeField()
  2. 7 sqlsrv/database.inc \DatabaseConnection_sqlsrv::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.

Return value

string The sanitized field name string.

Overrides DatabaseConnection::escapeField

File

sqlsrv/database.inc, line 374
Database interface code for Microsoft SQL Server.

Class

DatabaseConnection_sqlsrv
Summary of DatabaseConnection_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];
}