function db_escape_field
Same name in other branches
- 7.x includes/database/database.inc \db_escape_field()
Restricts a dynamic column or constraint name to safe characters.
Only keeps alphanumeric and underscores.
Parameters
string $field: The field name to escape.
Return value
string The escaped field name as a string.
Deprecated
in drupal:8.0.0 and is removed from drupal:9.0.0. Instead, get a database connection injected into your service from the container and call escapeField() on it. For example, $injected_database->escapeField($field);
See also
https://www.drupal.org/node/2993033
\Drupal\Core\Database\Connection::escapeField()
Related topics
1 call to db_escape_field()
- DatabaseLegacyTest::testDbEscapeField in core/
tests/ Drupal/ KernelTests/ Core/ Database/ DatabaseLegacyTest.php - Tests deprecation of the db_escape_field() function.
File
-
core/
includes/ database.inc, line 374
Code
function db_escape_field($field) {
@trigger_error('db_escape_field() is deprecated in drupal:8.0.0. It will be removed from drupal:9.0.0. Instead, get a database connection injected into your service from the container and call escapeField() on it. For example, $injected_database->escapeField($field). See https://www.drupal.org/node/2993033', E_USER_DEPRECATED);
return Database::getConnection()->escapeField($field);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.