function db_index_exists

Same name in other branches
  1. 7.x includes/database/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

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 indexExists() on it. For example, $injected_database->schema()->indexExists($table, $name);

See also

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

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

Related topics

1 call to db_index_exists()
DatabaseLegacyTest::testDbIndexExists in core/tests/Drupal/KernelTests/Core/Database/DatabaseLegacyTest.php
Tests deprecation of the db_index_exists() function.

File

core/includes/database.inc, line 676

Code

function db_index_exists($table, $name) {
    @trigger_error('db_index_exists() is deprecated in drupal:8.0.0. It will be removed from 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. For example, $injected_database->schema()->indexExists($table, $name). See https://www.drupal.org/node/2993033', E_USER_DEPRECATED);
    return Database::getConnection()->schema()
        ->indexExists($table, $name);
}

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