Skip to content

Kirby 5.0.4

$sql->createColumn()

Creates the CREATE TABLE syntax for a single column

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

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

Array with `query` and `key` strings, a `unique` boolean and a `bindings` array

This method modifies the existing $sql object it is applied to and returns it again.

Exceptions

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

Parent class

Kirby\Database\Sql