protected function DatabaseSchema_sqlite::createColumsSql

7.x schema.inc protected DatabaseSchema_sqlite::createColumsSql($tablename, $schema)

Build the SQL expression for creating columns.

1 call to DatabaseSchema_sqlite::createColumsSql()
DatabaseSchema_sqlite::createTableSql in drupal-7.x/includes/database/sqlite/schema.inc
Generate SQL to create a new table from a Drupal schema definition.

File

drupal-7.x/includes/database/sqlite/schema.inc, line 71
Database schema code for SQLite databases.

Class

DatabaseSchema_sqlite

Code

protected function createColumsSql($tablename, $schema) {
  $sql_array = array();

  // Add the SQL statement for each field.
  foreach ($schema['fields'] as $name => $field) {
    if (isset($field['type']) && $field['type'] == 'serial') {
      if (isset($schema['primary key']) && ($key = array_search($name, $schema['primary key'])) !== FALSE) {
        unset($schema['primary key'][$key]);
      }
    }
    $sql_array[] = $this->createFieldSql($name, $this->processField($field));
  }

  // Process keys.
  if (!empty($schema['primary key'])) {
    $sql_array[] = " PRIMARY KEY (" . $this->createKeySql($schema['primary key']) . ")";
  }

  return implode(", \n", $sql_array);
}