You are here

protected function DatabaseSchema_mysql::createKeysSql in Drupal 7

3 calls to DatabaseSchema_mysql::createKeysSql()
DatabaseSchema_mysql::addField in includes/database/mysql/schema.inc
Add a new field to a table.
DatabaseSchema_mysql::changeField in includes/database/mysql/schema.inc
Change a field definition.
DatabaseSchema_mysql::createTableSql in includes/database/mysql/schema.inc
Generate SQL to create a new table from a Drupal schema definition.

File

includes/database/mysql/schema.inc, line 269
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;
}