function Schema::createKeySql

Same name in this branch
  1. 9 core/modules/sqlite/src/Driver/Database/sqlite/Schema.php \Drupal\sqlite\Driver\Database\sqlite\Schema::createKeySql()
Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php \Drupal\Core\Database\Driver\sqlite\Schema::createKeySql()
  2. 8.9.x core/lib/Drupal/Core/Database/Driver/mysql/Schema.php \Drupal\Core\Database\Driver\mysql\Schema::createKeySql()
  3. 10 core/modules/sqlite/src/Driver/Database/sqlite/Schema.php \Drupal\sqlite\Driver\Database\sqlite\Schema::createKeySql()
  4. 10 core/modules/mysql/src/Driver/Database/mysql/Schema.php \Drupal\mysql\Driver\Database\mysql\Schema::createKeySql()
  5. 11.x core/modules/sqlite/src/Driver/Database/sqlite/Schema.php \Drupal\sqlite\Driver\Database\sqlite\Schema::createKeySql()
  6. 11.x core/modules/mysql/src/Driver/Database/mysql/Schema.php \Drupal\mysql\Driver\Database\mysql\Schema::createKeySql()
4 calls to Schema::createKeySql()
Schema::addIndex in core/modules/mysql/src/Driver/Database/mysql/Schema.php
Add an index.
Schema::addPrimaryKey in core/modules/mysql/src/Driver/Database/mysql/Schema.php
Add a primary key.
Schema::addUniqueKey in core/modules/mysql/src/Driver/Database/mysql/Schema.php
Add a unique key.
Schema::createKeysSql in core/modules/mysql/src/Driver/Database/mysql/Schema.php

File

core/modules/mysql/src/Driver/Database/mysql/Schema.php, line 363

Class

Schema
MySQL implementation of \Drupal\Core\Database\Schema.

Namespace

Drupal\mysql\Driver\Database\mysql

Code

protected function createKeySql($fields) {
    $return = [];
    foreach ($fields as $field) {
        if (is_array($field)) {
            $return[] = '`' . $field[0] . '`(' . $field[1] . ')';
        }
        else {
            $return[] = '`' . $field . '`';
        }
    }
    return implode(', ', $return);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.