0 follower

Final Class Yiisoft\Db\Constraint\DefaultValue

InheritanceYiisoft\Db\Constraint\DefaultValue

Represents a default value constraint in a database.

A default value constraint is a constraint that enforces a default value for a column.

It can be used to specify a default value for a column when a new row is inserted into the table, and no value is provided for that column.

Also allows you to define a default value as a constant, a PHP expression, or an SQL expression that will be evaluated by the database, and can be used in migrations to define the default value for a column when creating or modifying a table.

Public Methods

Hide inherited methods

Method Description Defined By
__construct() Yiisoft\Db\Constraint\DefaultValue

Property Details

Hide inherited properties

$columnNames public property
public array $columnNames = []
$name public property
public string $name ''
$value public property
public mixed $value null

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( string $name '', string[] $columnNames = [], mixed $value null )
$name string

The constraint name.

$columnNames string[]

The list of column names the constraint belongs to.

$value mixed

The default value as returned by the DBMS.

                public function __construct(
    public readonly string $name = '',
    public readonly array $columnNames = [],
    public readonly mixed $value = null,
) {}