You are here

public function Schema::introspectPrimaryKeyFields in Drupal driver for SQL Server and SQL Azure 8

Same name and namespace in other branches
  1. 8.2 drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php \Drupal\Driver\Database\sqlsrv\Schema::introspectPrimaryKeyFields()
  2. 3.0.x 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:

string $field:

Return value

string[]

3 calls to Schema::introspectPrimaryKeyFields()
Schema::addIndex in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Override DatabaseSchema::addIndex().
Schema::changeField in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Override DatabaseSchema::changeField().
Schema::compressPrimaryKeyIndex in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Sometimes the size of a table's primary key index needs to be reduced to allow for Primary XML Indexes.

File

drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php, line 1268
Definition of Drupal\Driver\Database\sqlsrv\Schema

Class

Schema

Namespace

Drupal\Driver\Database\sqlsrv

Code

public function introspectPrimaryKeyFields($table) {
  $data = $this
    ->queryColumnInformation($table, TRUE);

  // 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 array();
  }
  $result = array();
  $index = $data['indexes'][$data['primary_key_index']];
  foreach ($index['columns'] as $column) {
    if ($column['name'] != $this->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;
}