W3cubDocs

/Drupal 8

protected function Schema::createKeysSql

protected Schema::createKeysSql($spec)

File

core/lib/Drupal/Core/Database/Driver/mysql/Schema.php, line 272

Class

Schema
MySQL implementation of \Drupal\Core\Database\Schema.

Namespace

Drupal\Core\Database\Driver\mysql

Code

protected function createKeysSql($spec) {
  $keys = array();

  if (!empty($spec['primary key'])) {
    $keys[] = 'PRIMARY KEY (' . $this->createKeySql($spec['primary key']) . ')';
  }
  if (!empty($spec['unique keys'])) {
    foreach ($spec['unique keys'] as $key => $fields) {
      $keys[] = 'UNIQUE KEY `' . $key . '` (' . $this->createKeySql($fields) . ')';
    }
  }
  if (!empty($spec['indexes'])) {
    $indexes = $this->getNormalizedIndexes($spec);
    foreach ($indexes as $index => $fields) {
      $keys[] = 'INDEX `' . $index . '` (' . $this->createKeySql($fields) . ')';
    }
  }

  return $keys;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Database!Driver!mysql!Schema.php/function/Schema::createKeysSql/8.1.x