You are here

protected function Schema::primaryKeyName 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::primaryKeyName()
  2. 3.0.x 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.

4 calls to Schema::primaryKeyName()
Schema::addPrimaryKey in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Override DatabaseSchema::addPrimaryKey().
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. 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())
Schema::dropPrimaryKey in drivers/lib/Drupal/Driver/Database/sqlsrv/Schema.php
Override DatabaseSchema::dropPrimaryKey().

File

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

Class

Schema

Namespace

Drupal\Driver\Database\sqlsrv

Code

protected function primaryKeyName($table) {
  $table = $this->connection
    ->prefixTables('{' . $table . '}');
  return $this->connection
    ->query('SELECT name FROM sys.key_constraints WHERE parent_object_id = OBJECT_ID(:table) AND type = :type', array(
    ':table' => $table,
    ':type' => 'PK',
  ))
    ->fetchField();
}