Skip to content

Kirby 6.0.0

$sql->createColumn()

Creates the CREATE TABLE syntax for a single column

$sql->createColumn(string $name, array $column): array{query: string, bindings: array, key: string|null, unique: bool}

Parameters

Name Type Default Description
$namerequired string no default value Column name
$columnrequired array no default value Column definition array; valid keys: - type (required): Column template to use - unsigned: Whether an int column is signed or unsigned (boolean) - size: The size of varchar (int) - precision: The precision of a decimal type - decimalPlaces: The number of decimal places for a decimal type - 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{query: string, bindings: array<string, mixed>, key: string|null, unique: bool}

Exceptions

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

Parent class

Kirby\Database\Sql