1 schema.inc protected DatabaseSchema::buildTableNameCondition($table_name, $operator = '=', $add_prefix = TRUE)

Build a condition to match a table name against the 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 Backdrop 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 Backdrop tables or information associated with Backdrop 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

string $table_name: The name of the table in question.

string $operator: The operator to apply on the 'table' part of the condition.

bool $add_prefix: Boolean to indicate whether the table name needs to be prefixed.

Return value

QueryConditionInterface: A DatabaseCondition object.

File

core/includes/database/schema.inc, line 303
Generic Database schema code.

Class

DatabaseSchema
Base class for database schema definitions.

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 DatabaseCondition('AND');
  $condition->condition('table_catalog', $info['database']);
  $condition->condition('table_schema', $table_info['schema']);
  $condition->condition('table_name', $table_info['table'], $operator);
  return $condition;
}