// Provide defaults if needed.
$table +=
[ 'mysql_engine' => 'InnoDB',
'mysql_character_set' => 'utf8mb4',
];
$sql = "CREATE TABLE {" .
$name . "} (\n";
// Add the SQL statement for each field.
foreach ($table['fields'
] as $field_name =>
$field) { $sql .=
$this->
createFieldSql($field_name,
$this->
processField($field)) . ", \n";
} // Process keys & indexes.
if (!
empty($table['primary key'
]) &&
is_array($table['primary key'
])) { $this->
ensureNotNullPrimaryKey($table['primary key'
],
$table['fields'
]);
} $keys =
$this->
createKeysSql($table);
if (count($keys)) { $sql .=
implode(", \n",
$keys) . ", \n";
}