| Versionen | |
|---|---|
| drupal7 | protected DatabaseSchema::buildTableNameCondition($table_name, $operator = '=') |
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 includes/databases/mysql/schema.inc.
$table_name The name of the table to explode.
$operator The operator to apply on the 'table' part of the condition.
A DatabaseCondition object.
includes/
<?php
protected function buildTableNameCondition($table_name, $operator = '=') {
$info = Database::getConnectionInfo();
// The table name may describe the schema eg. schema.table.
if (strpos($table_name, '.')) {
list($schema, $table_name) = explode('.', $table_name);
}
else {
$schema = 'public';
}
$condition = new DatabaseCondition('AND');
$condition->condition('table_catalog', $info['default']['database']);
$condition->condition('table_schema', $schema);
$condition->condition('table_name', $table_name, $operator);
return $condition;
}
?>
Kommentare
Kommentar hinzufügen