You are here

protected function DatabaseSchema_mysql::buildTableNameCondition in Drupal 7

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 DatabaseSchema::buildTableNameCondition

1 call to DatabaseSchema_mysql::buildTableNameCondition()
DatabaseSchema_mysql::getComment in includes/database/mysql/schema.inc
Retrieve a table or column comment.

File

includes/database/mysql/schema.inc, line 57
Database schema code for MySQL database servers.

Class

DatabaseSchema_mysql

Code

protected function buildTableNameCondition($table_name, $operator = '=', $add_prefix = TRUE) {
  $info = $this->connection
    ->getConnectionOptions();

  // Ensure the table name is not surrounded with quotes as that is not
  // appropriate for schema queries.
  $quote_char = variable_get('mysql_identifier_quote_character', MYSQL_IDENTIFIER_QUOTE_CHARACTER_DEFAULT);
  $table_name = str_replace($quote_char, '', $table_name);
  $table_info = $this
    ->getPrefixInfo($table_name, $add_prefix);
  $condition = new DatabaseCondition('AND');
  $condition
    ->condition('table_schema', $table_info['database']);
  $condition
    ->condition('table_name', $table_info['table'], $operator);
  return $condition;
}