function Column::__construct
Constructor.
Parameters
string $name: The column name.
?ColumnType $type: (Optional) The column data type, generic. Each database will map this to its own definition. This argument is mandatory unless $dbSpecificExtra is specified. See \Drupal\Core\Database\SchemaDefinition\ColumnType for allowed values.
?string $description: (Optional) A string in non-markup plain text describing this field and its purpose. References to other tables should be enclosed in curly brackets. For example, the users_data table 'uid' field description might contain "The {users}.uid this record affects.".
?bool $serialize: (Optional) A boolean indicating whether the field will be stored as a serialized string. If NULL, it is not specified. Defaults to NULL.
?ColumnSize $size: (Optional) The column data size. This is a hint about the largest value the column will store. See \Drupal\Core\Database\SchemaDefinition\ColumnSize for allowed values.
?bool $notNull: (Optional) If true, no NULL values will be allowed in this database column. If false, NULL values will be allowed. If NULL, it is not specified. Defaults to NULL.
StringValue|IntValue|FloatValue|NullValue|null $default: (Optional) The field's default value.
?int $length: (Optional) The maximum length of a type 'char', 'varchar' or 'text' field. Ignored for other field types.
?bool $unsigned: (Optional) A boolean indicating whether a type 'int', 'float' and 'numeric' only is signed or unsigned. If NULL, it is not specified. Defaults to NULL.
?int $precision: (Optional) Mandatory for type 'numeric' fields, indicates the precision (total number of significant digits). Ignored for other field types.
?int $scale: (Optional) Mandatory for type 'numeric' fields, indicates the scale (decimal digits right of the decimal point). Ignored for other field types.
?bool $binary: (Optional) A boolean indicating that MySQL should force 'char', 'varchar' or 'text' fields to use case-sensitive binary collation. This has no effect on other database types for which case sensitivity is already the default behavior. If NULL, it is not specified. Defaults to NULL.
array<string,array<string,mixed>>|null $dbSpecificExtra: (Optional) If you need to use a column type not included in the officially supported list of types above, you can specify a type for each database backend. Specify this as an associative array having the database type ('mysql', 'sqlite', 'pgsql', 'oracle', etc.) as the key, and an array of extra information <string,mixed> as the value. If NULL, it is not specified. Defaults to NULL.
See also
\Drupal\Core\Database\SchemaDefinition\ColumnType
\Drupal\Core\Database\SchemaDefinition\ColumnSize
File
-
core/
lib/ Drupal/ Core/ Database/ SchemaDefinition/ Column.php, line 73
Class
- Column
- Describes a database table's column.
Namespace
Drupal\Core\Database\SchemaDefinitionCode
private function __construct(public readonly string $name, public readonly ?ColumnType $type = NULL, public readonly ?string $description = NULL, public readonly ?bool $serialize = NULL, public readonly ?ColumnSize $size = NULL, public readonly ?bool $notNull = NULL, public readonly StringValue|IntValue|FloatValue|NullValue|null $default = NULL, public readonly ?int $length = NULL, public readonly ?bool $unsigned = NULL, public readonly ?int $precision = NULL, public readonly ?int $scale = NULL, public readonly ?bool $binary = NULL, public readonly ?array $dbSpecificExtra = NULL) {
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.