protected function Schema::buildTableNameCondition

protected Schema::buildTableNameCondition($table_name, $operator = '=', $add_prefix = TRUE)

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.

File

core/lib/Drupal/Core/Database/Schema.php, line 141

Class

Schema
Provides a base implementation for Database Schema.

Namespace

Drupal\Core\Database

Code

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 = new 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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Database!Schema.php/function/Schema::buildTableNameCondition/8.1.x