public function Connection::escapeTable in Drupal driver for SQL Server and SQL Azure 8.2
Same name and namespace in other branches
- 8 drivers/lib/Drupal/Driver/Database/sqlsrv/Connection.php \Drupal\Driver\Database\sqlsrv\Connection::escapeTable()
Override DatabaseConnection::escapeTable().
@status needswork
Overrides Connection::escapeTable
1 call to Connection::escapeTable()
- Connection::prefixTable in drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Connection.php - Prefix a single table name.
File
- drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Connection.php, line 824 - 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 escapeTable($table) {
// A static cache is better suited for this.
static $tables = [];
if (isset($tables[$table])) {
return $tables[$table];
}
// Rescue the # prefix from the escaping.
$is_temporary = $table[0] == '#';
$is_temporary_global = $is_temporary && isset($table[1]) && $table[1] == '#';
// Any temporary table prefix will be removed.
$result = preg_replace('/[^A-Za-z0-9_.]+/', '', $table);
// Restore the temporary prefix.
if ($is_temporary) {
if ($is_temporary_global) {
$result = '##' . $result;
}
else {
$result = '#' . $result;
}
}
$tables[$table] = $result;
return $result;
}