protected function Schema::primaryKeyName in Drupal driver for SQL Server and SQL Azure 3.0.x
Same name and namespace in other branches
- 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php \Drupal\Driver\Database\sqlsrv\Schema::primaryKeyName()
- 8 drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php \Drupal\Driver\Database\sqlsrv\Schema::primaryKeyName()
Return the name of the primary key of a table if it exists.
Parameters
mixed $table: Table name.
4 calls to Schema::primaryKeyName()
- Schema::addPrimaryKey in drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php - Add a primary key.
- Schema::cleanUpPrimaryKey in drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php - Drop the primary key constraint.
- Schema::cleanUpTechnicalPrimaryColumn in drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php - Tries to clean up the technical primary column.
- Schema::dropPrimaryKey in drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php - Drop the primary key.
File
- drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php, line 1875
Class
Namespace
Drupal\Driver\Database\sqlsrvCode
protected function primaryKeyName($table) {
$prefixInfo = $this
->getPrefixInfo($table, TRUE);
$sql = 'SELECT name FROM sys.key_constraints WHERE parent_object_id = OBJECT_ID(:table) AND type = :type';
return $this->connection
->query($sql, [
':table' => $prefixInfo['table'],
':type' => 'PK',
])
->fetchField();
}