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;
}
doc_Drupal
2016-10-29 09:39:49
Comments
Leave a Comment

Please login to continue.