W3cubDocs

/Drupal 8

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.

MySQL uses databases like schemas rather than catalogs so when we build a condition to query the information_schema.tables, we set the default database as the schema unless specified otherwise, and exclude table_catalog from the condition criteria.

Overrides Schema::buildTableNameCondition

File

core/lib/Drupal/Core/Database/Driver/mysql/Schema.php, line 75

Class

Schema
MySQL implementation of \Drupal\Core\Database\Schema.

Namespace

Drupal\Core\Database\Driver\mysql

Code

protected function buildTableNameCondition($table_name, $operator = '=', $add_prefix = TRUE) {
  $table_info = $this->getPrefixInfo($table_name, $add_prefix);

  $condition = new Condition('AND');
  $condition->condition('table_schema', $table_info['database']);
  $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!Driver!mysql!Schema.php/function/Schema::buildTableNameCondition/8.1.x