public function Schema::tableExists in Drupal 10
Same name in this branch
- 10 core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::tableExists()
- 10 core/modules/sqlite/src/Driver/Database/sqlite/Schema.php \Drupal\sqlite\Driver\Database\sqlite\Schema::tableExists()
- 10 core/modules/pgsql/src/Driver/Database/pgsql/Schema.php \Drupal\pgsql\Driver\Database\pgsql\Schema::tableExists()
Check if a table exists.
Parameters
$table: The name of the table in drupal (no prefixing).
Return value
TRUE if the given table exists, otherwise FALSE.
Overrides Schema::tableExists
9 calls to Schema::tableExists()
- Schema::addField in core/
modules/ sqlite/ src/ Driver/ Database/ sqlite/ Schema.php - Add a new field to a table.
- Schema::addIndex in core/
modules/ sqlite/ src/ Driver/ Database/ sqlite/ Schema.php - Add an index.
- Schema::addPrimaryKey in core/
modules/ sqlite/ src/ Driver/ Database/ sqlite/ Schema.php - Add a primary key.
- Schema::addUniqueKey in core/
modules/ sqlite/ src/ Driver/ Database/ sqlite/ Schema.php - Add a unique key.
- Schema::alterTable in core/
modules/ sqlite/ src/ Driver/ Database/ sqlite/ Schema.php - Create a table with a new schema containing the old content.
File
- core/
modules/ sqlite/ src/ Driver/ Database/ sqlite/ Schema.php, line 31
Class
- Schema
- SQLite implementation of \Drupal\Core\Database\Schema.
Namespace
Drupal\sqlite\Driver\Database\sqliteCode
public function tableExists($table) {
$info = $this
->getPrefixInfo($table);
// Don't use {} around sqlite_master table.
return (bool) $this->connection
->query('SELECT 1 FROM ' . $info['schema'] . '.sqlite_master WHERE type = :type AND name = :name', [
':type' => 'table',
':name' => $info['table'],
])
->fetchField();
}