1.20.x schema.inc | public DatabaseSchema_mysql::indexExists($table, $name) |
Checks if an index exists in the given table.
Parameters
$table: The name of the table in Backdrop (no prefixing).
$name: The name of the index in Backdrop (no prefixing).
Return value
TRUE if the given index exists, otherwise FALSE.:
Overrides DatabaseSchema::indexExists
File
- drivers/
database_mysql/ schema.inc, line 406 - Database schema code for MySQL database servers.
Class
Code
public function indexExists($table, $name) {
// Returns one row for each column in the index. Result is string or FALSE.
// Details at http://dev.mysql.com/doc/refman/5.0/en/show-index.html
$row = $this->connection->query('SHOW INDEX FROM {' . $table . "} WHERE key_name = '$name'")->fetchAssoc();
return isset($row['Key_name']);
}