protected function Schema::createKeysSql in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Database/Driver/mysql/Schema.php \Drupal\Core\Database\Driver\mysql\Schema::createKeysSql()
3 calls to Schema::createKeysSql()
- Schema::addField in core/
lib/ Drupal/ Core/ Database/ Driver/ mysql/ Schema.php - Add a new field to a table.
- Schema::changeField in core/
lib/ Drupal/ Core/ Database/ Driver/ mysql/ Schema.php - Change a field definition.
- Schema::createTableSql in core/
lib/ Drupal/ Core/ Database/ Driver/ mysql/ Schema.php - Generate SQL to create a new table from a Drupal schema definition.
File
- core/
lib/ Drupal/ Core/ Database/ Driver/ mysql/ Schema.php, line 282
Class
- Schema
- MySQL implementation of \Drupal\Core\Database\Schema.
Namespace
Drupal\Core\Database\Driver\mysqlCode
protected function createKeysSql($spec) {
$keys = [];
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;
}