Column
in package
Read onlyYes
FinalYes
Attribute for mapping a property in an entity to a database column.
#[Entity(name: 'my_entity']
final class MyEntity {
#[Column(name: 'my_column', type: ColumnType::String, default: '')]
public string $myColumn = '';
}
Tags
Attributes
- #[Attribute]
- \Attribute::TARGET_PROPERTY
- #[Consumable]
- $since: '35.0.0'
Table of Contents
Properties
- $default : scalar|null
- $length : int|null
- $name : non-empty-lowercase-string
- $nullable : bool
- $type : ColumnType
Methods
- __construct() : mixed
Properties
$default
public
scalar|null
$default
= null
The default value for the column in the database.
$length
public
int|null
$length
= null
The length of the column (relevant for Types::STRING)
$name
public
non-empty-lowercase-string
$name
The name of the column in the database.
$nullable
public
bool
$nullable
= false
Whether the column is nullable in the database
$type
public
ColumnType
$type
The type of the column in the database.
Methods
__construct()
public
__construct(string $name, ColumnType $type[, int|null $length = null ][, bool $nullable = false ][, mixed $default = null ]) : mixed
Parameters
- $name : string
- $type : ColumnType
- $length : int|null = null
- $nullable : bool = false
- $default : mixed = null