DbDefault
extends ObjAttribute
in package
Attribute to specify a default value for a database column.
The value is inserted as-is into the DDL, so use raw SQL expressions (e.g., 'CURRENT_TIMESTAMP', 'NULL', '0', "'default_string'").
Usage:
#[DbDefault('CURRENT_TIMESTAMP')]
public DBDateTime $created_at;
#[DbDefault('0')]
public int $count;
Tags
Table of Contents
Properties
- $value : string
Methods
- __construct() : mixed
- Initialize the default value attribute.
- of() : static|false
- Extract an attribute instance from a reflected property.
Properties
$value
public
string
$value
Methods
__construct()
Initialize the default value attribute.
public
__construct(string $value) : mixed
Parameters
- $value : string
-
The SQL default value expression.
of()
Extract an attribute instance from a reflected property.
public
static of(ReflectionProperty $field) : static|false
Searches the property's attributes for one matching this class name and instantiates it with the attribute's arguments.
Parameters
- $field : ReflectionProperty
-
The property to inspect for attributes.
Return values
static|false —The attribute instance if found, false otherwise.