1 schema.inc public DatabaseSchema_mysql::indexExists($table, $name)

Checks if an index exists in the given table.

Parameters

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

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

Return value

bool: TRUE if the given index exists, otherwise FALSE.

Overrides DatabaseSchema::indexExists

File

core/includes/database/mysql/schema.inc, line 437
Database schema code for MySQL database servers.

Class

DatabaseSchema_mysql
Class to create and manipulate MySQL tables.

Code

public function indexExists($table, $name) {
  // Returns one row for each column in the index. Result is string or FALSE.
  // Details at https://dev.mysql.com/doc/refman/8.4/en/show-index.html
  $row = $this->connection->query('SHOW INDEX FROM {' . $table . "} WHERE key_name = '$name'")->fetchAssoc();
  return isset($row['Key_name']);
}