You are here

function db_escape_table in Drupal 8

Same name and namespace in other branches
  1. 4 includes/database.inc \db_escape_table()
  2. 5 includes/database.inc \db_escape_table()
  3. 6 includes/database.inc \db_escape_table()
  4. 7 includes/database/database.inc \db_escape_table()

Restricts a dynamic table name to safe characters.

Only keeps alphanumeric and underscores.

Parameters

$table: The table name to escape.

Return value

string The escaped table 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 escapeTable() on it. For example, $injected_database->escapeTable($table);

See also

https://www.drupal.org/node/2993033

\Drupal\Core\Database\Connection::escapeTable()

Related topics

1 call to db_escape_table()
DatabaseLegacyTest::testDbEscapeTable in core/tests/Drupal/KernelTests/Core/Database/DatabaseLegacyTest.php
Tests deprecation of the db_escape_table() function.

File

core/includes/database.inc, line 350
Core systems for the database layer.

Code

function db_escape_table($table) {
  @trigger_error('db_escape_table() 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 escapeTable() on it. For example, $injected_database->escapeTable($table). See https://www.drupal.org/node/2993033', E_USER_DEPRECATED);
  return Database::getConnection()
    ->escapeTable($table);
}