function DatabaseSchema_sqlite::createIndexSql

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

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

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