| Versionen | |
|---|---|
| drupal7 | public DatabaseSchema::tableExists($table) |
Check if a table exists.
$table The name of the table in drupal (no prefixing).
false is no table exists otherwise the actual table name.
includes/
<?php
public function tableExists($table) {
$condition = $this->buildTableNameCondition($this->connection->prefixTables('{' . $table . '}'));
$condition->compile($this->connection);
// Normally, we would heartily discourage the use of string
// concatination for conditionals like this however, we
// couldn't use db_select() here because it would prefix
// information_schema.tables and the query would fail.
// Don't use {} around information_schema table.
return db_query("SELECT table_name FROM information_schema.tables WHERE " . (string) $condition, $condition->arguments())->fetchField();
}
?>
Kommentare
Kommentar hinzufügen