You are here

public function Connection::escapeField in Zircon Profile 8

Same name in this branch
  1. 8 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::escapeField()
  2. 8 core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php \Drupal\Core\Database\Driver\pgsql\Connection::escapeField()
Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\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.

1 call to Connection::escapeField()
Connection::escapeField in core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
Escapes a field name string.
1 method overrides Connection::escapeField()
Connection::escapeField in core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
Escapes a field name string.

File

core/lib/Drupal/Core/Database/Connection.php, line 969
Contains \Drupal\Core\Database\Connection.

Class

Connection
Base Database API class.

Namespace

Drupal\Core\Database

Code

public function escapeField($field) {
  return preg_replace('/[^A-Za-z0-9_.]+/', '', $field);
}