Skip to content

Kirby 4.1.2

$sql->createColumn()

Creates the CREATE TABLE syntax for a single column

$sql->createColumn(string $name, array $column): array

Parameters

Name Type Default Description
$name * string Column name
$column * array Column definition array; valid keys:
- type (required): Column template to use
- null: Whether the column may be NULL (boolean)
- key: Index this column is part of; special values 'primary' for PRIMARY KEY and true for automatic naming
- unique: Whether the index (or if not set the column itself) has a UNIQUE constraint
- default: Default value of this column

Return type

array

Exceptions

Type Description
Kirby\Exception\InvalidArgumentException if no column type is given or the column type is not supported.

Parent class

Kirby\Database\Sql