public function DatabaseConnection_sqlsrv::escapeTable in Drupal driver for SQL Server and SQL Azure 7.2
Same name and namespace in other branches
- 7.3 sqlsrv/database.inc \DatabaseConnection_sqlsrv::escapeTable()
- 7 sqlsrv/database.inc \DatabaseConnection_sqlsrv::escapeTable()
Override DatabaseConnection::escapeTable().
@status needswork
Overrides DatabaseConnection::escapeTable
File
- sqlsrv/
database.inc, line 702 - Database interface code for Microsoft SQL Server.
Class
- DatabaseConnection_sqlsrv
- Summary of DatabaseConnection_sqlsrv
Code
public function escapeTable($table) {
// A static cache is better suited for this.
static $tables = array();
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;
}