public function Schema::introspectPrimaryKeyFields 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::introspectPrimaryKeyFields()
- 8 drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php \Drupal\Driver\Database\sqlsrv\Schema::introspectPrimaryKeyFields()
Get the list of fields participating in the Primary Key.
Parameters
string $table: Table name.
Return value
string[] Fields participating in the Primary Key.
2 calls to Schema::introspectPrimaryKeyFields()
- Schema::addIndex in drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php - Add an index.
- Schema::compressPrimaryKeyIndex in drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php - Compress Primary key Index.
File
- drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php, line 1751
Class
Namespace
Drupal\Driver\Database\sqlsrvCode
public function introspectPrimaryKeyFields($table) {
$data = $this
->queryColumnInformation($table);
// All primary keys have a default index,
// use that to see if we have a primary key
// before iterating.
if (!isset($data['primary_key_index']) || !isset($data['indexes'][$data['primary_key_index']])) {
return [];
}
$result = [];
$index = $data['indexes'][$data['primary_key_index']];
foreach ($index['columns'] as $column) {
if ($column['name'] != self::COMPUTED_PK_COLUMN_NAME) {
$result[$column['name']] = $column['name'];
}
// Get full column definition.
$c = $data['columns'][$column['name']];
// If this column depends on other columns
// the other columns are also part of the index!
// We don't support nested computed columns here.
foreach ($c['dependencies'] as $name => $order) {
$result[$name] = $name;
}
}
return $result;
}