protected function DatabaseSchema_mysql::createKeysSql

protected DatabaseSchema_mysql::createKeysSql($spec)

File

includes/database/mysql/schema.inc, line 264
Database schema code for MySQL database servers.

Class

DatabaseSchema_mysql

Code

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

  if (!empty($spec['primary key'])) {
    $keys[] = 'PRIMARY KEY (' . $this->createKeysSqlHelper($spec['primary key']) . ')';
  }
  if (!empty($spec['unique keys'])) {
    foreach ($spec['unique keys'] as $key => $fields) {
      $keys[] = 'UNIQUE KEY `' . $key . '` (' . $this->createKeysSqlHelper($fields) . ')';
    }
  }
  if (!empty($spec['indexes'])) {
    foreach ($spec['indexes'] as $index => $fields) {
      $keys[] = 'INDEX `' . $index . '` (' . $this->createKeysSqlHelper($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/includes!database!mysql!schema.inc/function/DatabaseSchema_mysql::createKeysSql/7.x