function Connection::prefixTables
Same name in other branches
- 9 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::prefixTables()
- 10 core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::prefixTables()
- 11.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::prefixTables()
Appends a database prefix to all tables in a query.
Queries sent to Drupal should wrap all table names in curly brackets. This function searches for this syntax and adds Drupal's table prefix to all tables, allowing Drupal to coexist with other systems in the same database and/or schema if necessary.
Parameters
string $sql: A string containing a partial or entire SQL query.
Return value
string The properly-prefixed string.
3 calls to Connection::prefixTables()
- Connection::makeSequenceName in core/
lib/ Drupal/ Core/ Database/ Connection.php - Creates the appropriate sequence name for a given table and serial field.
- Connection::prepareQuery in core/
lib/ Drupal/ Core/ Database/ Driver/ sqlite/ Connection.php - Prepares a query string and returns the prepared statement.
- Connection::prepareQuery in core/
lib/ Drupal/ Core/ Database/ Connection.php - Prepares a query string and returns the prepared statement.
File
-
core/
lib/ Drupal/ Core/ Database/ Connection.php, line 342
Class
- Connection
- Base Database API class.
Namespace
Drupal\Core\DatabaseCode
public function prefixTables($sql) {
return str_replace($this->prefixSearch, $this->prefixReplace, $sql);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.