function db_table_exists

Same name in other branches
  1. 7.x includes/database/database.inc \db_table_exists()

Checks if a table exists.

Parameters

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

Return value

bool TRUE if the given table exists, otherwise FALSE.

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Instead, get a database connection injected into your service from the container, get its schema driver, and call tableExists() on it. For example, $injected_database->schema()->tableExists($table);

See also

https://www.drupal.org/node/2993033

\Drupal\Core\Database\Schema::tableExists()

Related topics

1 call to db_table_exists()
DatabaseLegacyTest::testDbTableExists in core/tests/Drupal/KernelTests/Core/Database/DatabaseLegacyTest.php
Tests the db_table_exists() function.

File

core/includes/database.inc, line 698

Code

function db_table_exists($table) {
    @trigger_error('db_table_exists() is deprecated in drupal:8.0.0. It will be removed from drupal:9.0.0. Use $injected_database->schema()->tableExists($table) instead. See https://www.drupal.org/node/2993033', E_USER_DEPRECATED);
    return Database::getConnection()->schema()
        ->tableExists($table);
}

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