W3cubDocs

/Drupal 8

protected function Schema::createColumnsSql

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

Build the SQL expression for creating columns.

File

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

Class

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

Namespace

Drupal\Core\Database\Driver\sqlite

Code

protected function createColumnsSql($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);
}

© 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::createColumnsSql/8.1.x