public function Schema::introspectPrimaryKeyFields in Drupal driver for SQL Server and SQL Azure 4.0.x
Same name and namespace in other branches
- 4.2.x src/Driver/Database/sqlsrv/Schema.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Schema::introspectPrimaryKeyFields()
- 3.1.x src/Driver/Database/sqlsrv/Schema.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Schema::introspectPrimaryKeyFields()
- 4.1.x src/Driver/Database/sqlsrv/Schema.php \Drupal\sqlsrv\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 src/
Driver/ Database/ sqlsrv/ Schema.php - Add an index.
- Schema::compressPrimaryKeyIndex in src/
Driver/ Database/ sqlsrv/ Schema.php - Compress Primary key Index.
File
- src/
Driver/ Database/ sqlsrv/ Schema.php, line 1711
Class
Namespace
Drupal\sqlsrv\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;
}