protected function DatabaseSchema_sqlsrv::primaryKeyName in Drupal driver for SQL Server and SQL Azure 7.2
Same name and namespace in other branches
- 7.3 sqlsrv/schema.inc \DatabaseSchema_sqlsrv::primaryKeyName()
- 7 sqlsrv/schema.inc \DatabaseSchema_sqlsrv::primaryKeyName()
Return the name of the primary key of a table if it exists.
4 calls to DatabaseSchema_sqlsrv::primaryKeyName()
- DatabaseSchema_sqlsrv::addPrimaryKey in sqlsrv/
schema.inc - Override DatabaseSchema::addPrimaryKey().
- DatabaseSchema_sqlsrv::cleanUpPrimaryKey in sqlsrv/
schema.inc - Drop the primary key constraint.
- DatabaseSchema_sqlsrv::cleanUpTechnicalPrimaryColumn in sqlsrv/
schema.inc - Tries to clean up the technical primary column. It will be deleted if (a) It is not being used as the current primary key and... (b) There is no unique constraint because they depend on this column (see addUniqueKey())
- DatabaseSchema_sqlsrv::dropPrimaryKey in sqlsrv/
schema.inc - Override DatabaseSchema::dropPrimaryKey().
File
- sqlsrv/
schema.inc, line 1527 - Database schema code for Microsoft SQL Server database servers.
Class
Code
protected function primaryKeyName($table) {
$table = $this->connection
->prefixTables('{' . $table . '}');
return $this->connection
->query_direct('SELECT name FROM sys.key_constraints WHERE parent_object_id = OBJECT_ID(:table) AND type = :type', array(
':table' => $table,
':type' => 'PK',
))
->fetchField();
}