You are here

function _db_create_keys_sql in Drupal 6

Same name and namespace in other branches
  1. 7 includes/database/database.inc \_db_create_keys_sql()

Related topics

3 calls to _db_create_keys_sql()
db_add_field in includes/database.mysql-common.inc
Add a new field to a table.
db_change_field in includes/database.mysql-common.inc
Change a field definition.
db_create_table_sql in includes/database.mysql-common.inc
Generate SQL to create a new table from a Drupal schema definition.

File

includes/database.mysql-common.inc, line 96
Functions shared between mysql and mysqli database engines.

Code

function _db_create_keys_sql($spec) {
  $keys = array();
  if (!empty($spec['primary key'])) {
    $keys[] = 'PRIMARY KEY (' . _db_create_key_sql($spec['primary key']) . ')';
  }
  if (!empty($spec['unique keys'])) {
    foreach ($spec['unique keys'] as $key => $fields) {
      $keys[] = 'UNIQUE KEY ' . $key . ' (' . _db_create_key_sql($fields) . ')';
    }
  }
  if (!empty($spec['indexes'])) {
    foreach ($spec['indexes'] as $index => $fields) {
      $keys[] = 'INDEX ' . $index . ' (' . _db_create_key_sql($fields) . ')';
    }
  }
  return $keys;
}