W3cubDocs

/Drupal 8

protected function Schema::createIndexSql

protected Schema::createIndexSql($tablename, $schema)

Build the SQL expression for indexes.

File

core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php, line 56

Class

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

Namespace

Drupal\Core\Database\Driver\sqlite

Code

protected function createIndexSql($tablename, $schema) {
  $sql = array();
  $info = $this->getPrefixInfo($tablename);
  if (!empty($schema['unique keys'])) {
    foreach ($schema['unique keys'] as $key => $fields) {
      $sql[] = 'CREATE UNIQUE INDEX ' . $info['schema'] . '.' . $info['table'] . '_' . $key . ' ON ' . $info['table'] . ' (' . $this->createKeySql($fields) . ")\n";
    }
  }
  if (!empty($schema['indexes'])) {
    foreach ($schema['indexes'] as $key => $fields) {
      $sql[] = 'CREATE INDEX ' . $info['schema'] . '.' . $info['table'] . '_' . $key . ' ON ' . $info['table'] . ' (' . $this->createKeySql($fields) . ")\n";
    }
  }
  return $sql;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Database!Driver!sqlite!Schema.php/function/Schema::createIndexSql/8.1.x