function Schema::createColumnsSql
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php \Drupal\Core\Database\Driver\sqlite\Schema::createColumnsSql()
- 10 core/modules/sqlite/src/Driver/Database/sqlite/Schema.php \Drupal\sqlite\Driver\Database\sqlite\Schema::createColumnsSql()
- 11.x core/modules/sqlite/src/Driver/Database/sqlite/Schema.php \Drupal\sqlite\Driver\Database\sqlite\Schema::createColumnsSql()
Build the SQL expression for creating columns.
1 call to Schema::createColumnsSql()
- Schema::createTableSql in core/
modules/ sqlite/ src/ Driver/ Database/ sqlite/ Schema.php - Generate SQL to create a new table from a Drupal schema definition.
File
-
core/
modules/ sqlite/ src/ Driver/ Database/ sqlite/ Schema.php, line 89
Class
- Schema
- SQLite implementation of \Drupal\Core\Database\Schema.
Namespace
Drupal\sqlite\Driver\Database\sqliteCode
protected function createColumnsSql($tablename, $schema) {
$sql_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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.