protected function DatabaseSchema_sqlsrv::uniqueKeyExists in Drupal driver for SQL Server and SQL Azure 7
Same name and namespace in other branches
- 7.3 sqlsrv/schema.inc \DatabaseSchema_sqlsrv::uniqueKeyExists()
- 7.2 sqlsrv/schema.inc \DatabaseSchema_sqlsrv::uniqueKeyExists()
Find if an unique key exists.
@status tested
4 calls to DatabaseSchema_sqlsrv::uniqueKeyExists()
- DatabaseSchema_sqlsrv::addUniqueKey in sqlsrv/
schema.inc - Override DatabaseSchema::addUniqueKey().
- DatabaseSchema_sqlsrv::changeField in sqlsrv/
schema.inc - Override DatabaseSchema::changeField().
- DatabaseSchema_sqlsrv::dropFieldRelatedObjects in sqlsrv/
schema.inc - Drop the related objects of a column (indexes, constraints, etc.).
- DatabaseSchema_sqlsrv::dropUniqueKey in sqlsrv/
schema.inc - Override DatabaseSchema::dropUniqueKey().
File
- sqlsrv/
schema.inc, line 915 - Database schema code for Microsoft SQL Server database servers.
Class
Code
protected function uniqueKeyExists($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 . '_unique',
))
->fetchField();
}