function Schema::tableExists

Check if a table exists.

Parameters

$table: The name of the table in drupal (no prefixing).

Return value

bool 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.

... See full list

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\sqlite

Code

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();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.