function db_escape_table

Same name in other branches
  1. 7.x 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

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.