public function Connection::escapeField in Drupal driver for SQL Server and SQL Azure 8
Same name and namespace in other branches
- 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/Connection.php \Drupal\Driver\Database\sqlsrv\Connection::escapeField()
- 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 394 - 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\sqlsrvCode
public function escapeField($field) {
// TODO: Not really clear if using a cache here is really useful as the uncached implementation
// is fast out of the box anyways. Needs profiling.
if ($cache = $this->cache
->get($field, 'schema_escapeField')) {
return $cache->data;
}
if (strlen($field) > 0) {
$result = implode('.', array_map(array(
$this,
'quoteIdentifier',
), explode('.', preg_replace('/[^A-Za-z0-9_.]+/', '', $field))));
}
else {
$result = '';
}
$this->cache
->set($field, $result, 'schema_escapeField');
return $result;
}