function Schema::buildTableNameCondition
Same name in this branch
- 8.9.x core/lib/Drupal/Core/Database/Driver/mysql/Schema.php \Drupal\Core\Database\Driver\mysql\Schema::buildTableNameCondition()
Same name in other branches
- 9 core/modules/mysql/src/Driver/Database/mysql/Schema.php \Drupal\mysql\Driver\Database\mysql\Schema::buildTableNameCondition()
- 9 core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::buildTableNameCondition()
- 10 core/modules/mysql/src/Driver/Database/mysql/Schema.php \Drupal\mysql\Driver\Database\mysql\Schema::buildTableNameCondition()
- 10 core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::buildTableNameCondition()
- 11.x core/modules/mysql/src/Driver/Database/mysql/Schema.php \Drupal\mysql\Driver\Database\mysql\Schema::buildTableNameCondition()
- 11.x core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::buildTableNameCondition()
Build a condition to match a table name against a standard information_schema.
The information_schema is a SQL standard that provides information about the database server and the databases, schemas, tables, columns and users within it. This makes information_schema a useful tool to use across the drupal database drivers and is used by a few different functions. The function below describes the conditions to be meet when querying information_schema.tables for drupal tables or information associated with drupal tables. Even though this is the standard method, not all databases follow standards and so this method should be overwritten by a database driver if the database provider uses alternate methods. Because information_schema.tables is used in a few different functions, a database driver will only need to override this function to make all the others work. For example see core/includes/databases/mysql/schema.inc.
Parameters
$table_name: The name of the table in question.
$operator: The operator to apply on the 'table' part of the condition.
$add_prefix: Boolean to indicate whether the table name needs to be prefixed.
Return value
\Drupal\Core\Database\Query\Condition A Condition object.
3 calls to Schema::buildTableNameCondition()
- Schema::fieldExists in core/
lib/ Drupal/ Core/ Database/ Schema.php - Check if a column exists in the given table.
- Schema::findTables in core/
lib/ Drupal/ Core/ Database/ Schema.php - Finds all tables that are like the specified base table name.
- Schema::tableExists in core/
lib/ Drupal/ Core/ Database/ Schema.php - Check if a table exists.
1 method overrides Schema::buildTableNameCondition()
- Schema::buildTableNameCondition in core/
lib/ Drupal/ Core/ Database/ Driver/ mysql/ Schema.php - Build a condition to match a table name against a standard information_schema.
File
-
core/
lib/ Drupal/ Core/ Database/ Schema.php, line 146
Class
- Schema
- Provides a base implementation for Database Schema.
Namespace
Drupal\Core\DatabaseCode
protected function buildTableNameCondition($table_name, $operator = '=', $add_prefix = TRUE) {
$info = $this->connection
->getConnectionOptions();
// Retrieve the table name and schema
$table_info = $this->getPrefixInfo($table_name, $add_prefix);
$condition = $this->connection
->condition('AND');
$condition->condition('table_catalog', $info['database']);
$condition->condition('table_schema', $table_info['schema']);
$condition->condition('table_name', $table_info['table'], $operator);
return $condition;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.