You are here

public function DatabaseSchema_sqlsrv::indexExists in Drupal driver for SQL Server and SQL Azure 7

Same name and namespace in other branches
  1. 7.3 sqlsrv/schema.inc \DatabaseSchema_sqlsrv::indexExists()
  2. 7.2 sqlsrv/schema.inc \DatabaseSchema_sqlsrv::indexExists()

Override DatabaseSchema::indexExists().

@status tested

Overrides DatabaseSchema::indexExists

2 calls to DatabaseSchema_sqlsrv::indexExists()
DatabaseSchema_sqlsrv::addIndex in sqlsrv/schema.inc
Override DatabaseSchema::addIndex().
DatabaseSchema_sqlsrv::dropIndex in sqlsrv/schema.inc
Override DatabaseSchema::dropIndex().

File

sqlsrv/schema.inc, line 958
Database schema code for Microsoft SQL Server database servers.

Class

DatabaseSchema_sqlsrv

Code

public function indexExists($table, $name) {
  $table = $this->connection
    ->prefixTables('{' . $table . '}');
  return (bool) $this->connection
    ->query('SELECT 1 FROM sys.indexes WHERE object_id = OBJECT_ID(:table) AND name = :name', array(
    ':table' => $table,
    ':name' => $name . '_idx',
  ))
    ->fetchField();
}