You are here

function db_index_exists in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/includes/database.inc \db_index_exists()

Checks if an index exists in the given table.

Parameters

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

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

Return value

bool TRUE if the given index exists, otherwise FALSE.

Deprecated

as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get a database connection injected into your service from the container, get its schema driver, and call indexExists() on it. E.g. $injected_database->schema()->indexExists($table, $name);

See also

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

Related topics

4 calls to db_index_exists()
RegressionTest::testDBIndexExists in core/modules/system/src/Tests/Database/RegressionTest.php
Tests the db_index_exists() function.
SqlContentEntityStorageSchemaIndexTest::testIndex in core/modules/system/src/Tests/Entity/Update/SqlContentEntityStorageSchemaIndexTest.php
Tests entity and field schema database updates and execution order.
UpdatePathTestBaseTest::testUpdateHookN in core/modules/system/src/Tests/Update/UpdatePathTestBaseTest.php
Test that updates are properly run.
UpdateSchemaTest::testUpdateHooks in core/modules/system/src/Tests/Update/UpdateSchemaTest.php
Tests that update hooks are properly run.

File

core/includes/database.inc, line 618
Core systems for the database layer.

Code

function db_index_exists($table, $name) {
  return Database::getConnection()
    ->schema()
    ->indexExists($table, $name);
}