_db_create_keys_sql
Related topics
- Schema API
- A Drupal schema definition is an array structure representing one or
more tables and their related keys and indexes. A schema is defined by
hook_schema(), which usually lives in a modulename.install file.
File
- drupal/includes/database.mysql-common.inc, line 95
- Functions shared between mysql and mysqli database engines.
Code
<?php
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;
}
?>