You are here

protected function DatabaseSchema_sqlite::createIndexSql in Drupal 7

Build the SQL expression for indexes.

4 calls to DatabaseSchema_sqlite::createIndexSql()
DatabaseSchema_sqlite::addIndex in includes/database/sqlite/schema.inc
Add an index.
DatabaseSchema_sqlite::addUniqueKey in includes/database/sqlite/schema.inc
Add a unique key.
DatabaseSchema_sqlite::createTableSql in includes/database/sqlite/schema.inc
Generate SQL to create a new table from a Drupal schema definition.
DatabaseSchema_sqlite::renameTable in includes/database/sqlite/schema.inc
Rename a table.

File

includes/database/sqlite/schema.inc, line 52
Database schema code for SQLite databases.

Class

DatabaseSchema_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;
}