0 follower

Final Class Yiisoft\Db\Schema\Column\ArrayColumn

InheritanceYiisoft\Db\Schema\Column\ArrayColumn » Yiisoft\Db\Schema\Column\AbstractArrayColumn » Yiisoft\Db\Schema\Column\AbstractColumn
ImplementsYiisoft\Db\Schema\Column\ColumnInterface

Represents an array column with eager parsing values retrieved from the database.

See also Yiisoft\Db\Schema\Column\ArrayLazyColumn for an array column with lazy parsing values retrieved from the database.

Protected Properties

Hide inherited properties

Property Type Description Defined By
$column Yiisoft\Db\Schema\Column\ColumnInterface|null The column of an array item. Yiisoft\Db\Schema\Column\AbstractArrayColumn
$dimension integer The dimension of array, must be greater than 0. Yiisoft\Db\Schema\Column\AbstractArrayColumn

Public Methods

Hide inherited methods

Method Description Defined By
__construct() Yiisoft\Db\Schema\Column\AbstractColumn
autoIncrement() Yiisoft\Db\Schema\Column\AbstractColumn
check() Yiisoft\Db\Schema\Column\AbstractColumn
column() Set column of an array item. Yiisoft\Db\Schema\Column\AbstractArrayColumn
comment() Yiisoft\Db\Schema\Column\AbstractColumn
computed() Yiisoft\Db\Schema\Column\AbstractColumn
dbType() Yiisoft\Db\Schema\Column\AbstractColumn
dbTypecast() Yiisoft\Db\Schema\Column\AbstractArrayColumn
defaultValue() Yiisoft\Db\Schema\Column\AbstractColumn
dimension() Set dimension of an array, must be greater than 0. Yiisoft\Db\Schema\Column\AbstractArrayColumn
extra() Yiisoft\Db\Schema\Column\AbstractColumn
getCheck() Yiisoft\Db\Schema\Column\AbstractColumn
getColumn() Yiisoft\Db\Schema\Column\AbstractArrayColumn
getComment() Yiisoft\Db\Schema\Column\AbstractColumn
getDbType() Yiisoft\Db\Schema\Column\AbstractColumn
getDefaultValue() Yiisoft\Db\Schema\Column\AbstractColumn
getDimension() Yiisoft\Db\Schema\Column\AbstractArrayColumn
getExtra() Yiisoft\Db\Schema\Column\AbstractColumn
getName() Yiisoft\Db\Schema\Column\AbstractColumn
getReference() Yiisoft\Db\Schema\Column\AbstractColumn
getScale() Yiisoft\Db\Schema\Column\AbstractColumn
getSize() Yiisoft\Db\Schema\Column\AbstractColumn
getType() Yiisoft\Db\Schema\Column\AbstractColumn
hasDefaultValue() Yiisoft\Db\Schema\Column\AbstractColumn
isAutoIncrement() Yiisoft\Db\Schema\Column\AbstractColumn
isComputed() Yiisoft\Db\Schema\Column\AbstractColumn
isNotNull() Yiisoft\Db\Schema\Column\AbstractColumn
isPrimaryKey() Yiisoft\Db\Schema\Column\AbstractColumn
isUnique() Yiisoft\Db\Schema\Column\AbstractColumn
isUnsigned() Yiisoft\Db\Schema\Column\AbstractColumn
notNull() Yiisoft\Db\Schema\Column\AbstractColumn
null() Yiisoft\Db\Schema\Column\AbstractColumn
phpTypecast() Yiisoft\Db\Schema\Column\ArrayColumn
primaryKey() Yiisoft\Db\Schema\Column\AbstractColumn
reference() Yiisoft\Db\Schema\Column\AbstractColumn
scale() Yiisoft\Db\Schema\Column\AbstractColumn
size() Yiisoft\Db\Schema\Column\AbstractColumn
type() Yiisoft\Db\Schema\Column\AbstractColumn
unique() Yiisoft\Db\Schema\Column\AbstractColumn
unsigned() Yiisoft\Db\Schema\Column\AbstractColumn
withName() Yiisoft\Db\Schema\Column\AbstractColumn

Constants

Hide inherited constants

Constant Value Description Defined By
DEFAULT_TYPE \Yiisoft\Db\Constant\ColumnType::ARRAY Yiisoft\Db\Schema\Column\AbstractArrayColumn

Method Details

Hide inherited methods

__construct() public method
public __construct( string|null $type null, boolean $autoIncrement false, string|null $check null, string|null $comment null, boolean $computed false, string|null $dbType null, string|null $extra null, boolean $primaryKey false, string|null $name null, boolean|null $notNull null, Yiisoft\Db\Constraint\ForeignKey|null $reference null, integer|null $scale null, integer|null $size null, boolean $unique false, boolean $unsigned false, mixed $args ): mixed
$type string|null

The column's abstract type.

$autoIncrement boolean

Whether the column is auto-incremental.

$check string|null

The check constraint for the column.

$comment string|null

The column's comment.

$computed boolean

Whether the column is a computed column.

$dbType string|null

The column's database type.

$extra string|null

Any extra information that needs to be appended to the column's definition.

$primaryKey boolean

Whether the column is a primary key.

$name string|null

The column's name.

$notNull boolean|null

Whether the column is not nullable.

$reference Yiisoft\Db\Constraint\ForeignKey|null

The foreign key constraint.

$scale integer|null

The number of digits to the right of the decimal point.

$size integer|null

The column's size.

$unique boolean

Whether the column is unique.

$unsigned boolean

Whether the column is unsigned.

$args mixed

Additional arguments to be passed to the constructor.

                public function __construct(
    ?string $type = null,
    private bool $autoIncrement = false,
    private ?string $check = null,
    private ?string $comment = null,
    private bool $computed = false,
    private ?string $dbType = null,
    private ?string $extra = null,
    private bool $primaryKey = false,
    private ?string $name = null,
    private ?bool $notNull = null,
    private ?ForeignKey $reference = null,
    private ?int $scale = null,
    private ?int $size = null,
    private bool $unique = false,
    private bool $unsigned = false,
    mixed ...$args,
) {
    $this->type = $type ?? static::DEFAULT_TYPE;
    if (array_key_exists('defaultValue', $args)) {
        $this->defaultValue = $args['defaultValue'];
        unset($args['defaultValue']);
    }
    /** @psalm-var array<string, mixed> $args */
    foreach ($args as $property => $value) {
        if (property_exists($this, $property)) {
            $this->$property = $value;
        }
    }
}

            
autoIncrement() public method
public autoIncrement( boolean $autoIncrement true ): Yiisoft\Db\Schema\Column\ArrayColumn
$autoIncrement boolean

                public function autoIncrement(bool $autoIncrement = true): static
{
    $this->autoIncrement = $autoIncrement;
    return $this;
}

            
check() public method
public check( string|null $check ): Yiisoft\Db\Schema\Column\ArrayColumn
$check string|null

                public function check(?string $check): static
{
    $this->check = $check;
    return $this;
}

            
column() public method

Defined in: Yiisoft\Db\Schema\Column\AbstractArrayColumn::column()

Set column of an array item.

public column( Yiisoft\Db\Schema\Column\ColumnInterface|null $column ): Yiisoft\Db\Schema\Column\ArrayColumn
$column Yiisoft\Db\Schema\Column\ColumnInterface|null

                public function column(?ColumnInterface $column): static
{
    $this->column = $column;
    return $this;
}

            
comment() public method
public comment( string|null $comment ): Yiisoft\Db\Schema\Column\ArrayColumn
$comment string|null

                public function comment(?string $comment): static
{
    $this->comment = $comment;
    return $this;
}

            
computed() public method
public computed( boolean $computed true ): Yiisoft\Db\Schema\Column\ArrayColumn
$computed boolean

                public function computed(bool $computed = true): static
{
    $this->computed = $computed;
    return $this;
}

            
dbType() public method
public dbType( string|null $dbType ): Yiisoft\Db\Schema\Column\ArrayColumn
$dbType string|null

                public function dbType(?string $dbType): static
{
    $this->dbType = $dbType;
    return $this;
}

            
dbTypecast() public method
public dbTypecast( iterable|Yiisoft\Db\Schema\Data\LazyArrayInterface|Yiisoft\Db\Query\QueryInterface|string|null $value ): Yiisoft\Db\Expression\ExpressionInterface|null
$value iterable|Yiisoft\Db\Schema\Data\LazyArrayInterface|Yiisoft\Db\Query\QueryInterface|string|null

                public function dbTypecast(mixed $value): ?ExpressionInterface
{
    if ($value === null || $value instanceof ExpressionInterface) {
        return $value;
    }
    return new ArrayValue($value, $this);
}

            
defaultValue() public method
public defaultValue( mixed $defaultValue ): Yiisoft\Db\Schema\Column\ArrayColumn
$defaultValue mixed

                public function defaultValue(mixed $defaultValue): static
{
    $this->defaultValue = $defaultValue;
    return $this;
}

            
dimension() public method

Defined in: Yiisoft\Db\Schema\Column\AbstractArrayColumn::dimension()

Set dimension of an array, must be greater than 0.

public dimension( integer $dimension ): Yiisoft\Db\Schema\Column\ArrayColumn
$dimension integer

                public function dimension(int $dimension): static
{
    $this->dimension = $dimension;
    return $this;
}

            
extra() public method
public extra( string|null $extra ): Yiisoft\Db\Schema\Column\ArrayColumn
$extra string|null

                public function extra(?string $extra): static
{
    $this->extra = $extra;
    return $this;
}

            
getCheck() public method
public getCheck( ): string|null

                public function getCheck(): ?string
{
    return $this->check;
}

            
getColumn() public method
public getColumn( ): Yiisoft\Db\Schema\Column\ColumnInterface|null
return Yiisoft\Db\Schema\Column\ColumnInterface|null

The column of an array item.

                public function getColumn(): ?ColumnInterface
{
    return $this->column;
}

            
getComment() public method
public getComment( ): string|null

                public function getComment(): ?string
{
    return $this->comment;
}

            
getDbType() public method
public getDbType( ): string|null

                public function getDbType(): ?string
{
    return $this->dbType;
}

            
getDefaultValue() public method
public getDefaultValue( ): mixed

                public function getDefaultValue(): mixed
{
    return $this->defaultValue ?? null;
}

            
getDimension() public method
public getDimension( ): integer
return integer

The dimension of the array.

                public function getDimension(): int
{
    return $this->dimension;
}

            
getExtra() public method
public getExtra( ): string|null

                public function getExtra(): ?string
{
    return $this->extra;
}

            
getName() public method
public getName( ): string|null

                public function getName(): ?string
{
    return $this->name;
}

            
getReference() public method
public getReference( ): Yiisoft\Db\Constraint\ForeignKey|null

                public function getReference(): ?ForeignKey
{
    return $this->reference;
}

            
getScale() public method
public getScale( ): integer|null

                public function getScale(): ?int
{
    return $this->scale;
}

            
getSize() public method
public getSize( ): integer|null

                public function getSize(): ?int
{
    return $this->size;
}

            
getType() public method
public getType( ): string

                public function getType(): string
{
    return $this->type;
}

            
hasDefaultValue() public method
public hasDefaultValue( ): boolean

                public function hasDefaultValue(): bool
{
    return property_exists($this, 'defaultValue');
}

            
isAutoIncrement() public method
public isAutoIncrement( ): boolean

                public function isAutoIncrement(): bool
{
    return $this->autoIncrement;
}

            
isComputed() public method
public isComputed( ): boolean

                public function isComputed(): bool
{
    return $this->computed;
}

            
isNotNull() public method
public isNotNull( ): boolean|null

                public function isNotNull(): ?bool
{
    return $this->notNull;
}

            
isPrimaryKey() public method
public isPrimaryKey( ): boolean

                public function isPrimaryKey(): bool
{
    return $this->primaryKey;
}

            
isUnique() public method
public isUnique( ): boolean

                public function isUnique(): bool
{
    return $this->unique;
}

            
isUnsigned() public method
public isUnsigned( ): boolean

                public function isUnsigned(): bool
{
    return $this->unsigned;
}

            
notNull() public method
public notNull( boolean|null $notNull true ): Yiisoft\Db\Schema\Column\ArrayColumn
$notNull boolean|null

                public function notNull(?bool $notNull = true): static
{
    $this->notNull = $notNull;
    return $this;
}

            
null() public method
public null( ): Yiisoft\Db\Schema\Column\ArrayColumn

                public function null(): static
{
    $this->notNull = false;
    return $this;
}

            
phpTypecast() public method

public phpTypecast( string|null $value ): array|null
$value string|null

The string retrieved value from the database that can be parsed into an array.

                public function phpTypecast(mixed $value): ?array
{
    if (is_string($value)) {
        return (new LazyArray($value, $this->getColumn(), $this->getDimension()))->getValue();
    }
    return $value;
}

            
primaryKey() public method
public primaryKey( boolean $primaryKey true ): Yiisoft\Db\Schema\Column\ArrayColumn
$primaryKey boolean

                public function primaryKey(bool $primaryKey = true): static
{
    $this->primaryKey = $primaryKey;
    return $this;
}

            
reference() public method
public reference( Yiisoft\Db\Constraint\ForeignKey|null $reference ): Yiisoft\Db\Schema\Column\ArrayColumn
$reference Yiisoft\Db\Constraint\ForeignKey|null

                public function reference(?ForeignKey $reference): static
{
    $this->reference = $reference;
    return $this;
}

            
scale() public method
public scale( integer|null $scale ): Yiisoft\Db\Schema\Column\ArrayColumn
$scale integer|null

                public function scale(?int $scale): static
{
    $this->scale = $scale;
    return $this;
}

            
size() public method
public size( integer|null $size ): Yiisoft\Db\Schema\Column\ArrayColumn
$size integer|null

                public function size(?int $size): static
{
    $this->size = $size;
    return $this;
}

            
throwWrongTypeException() protected method
protected throwWrongTypeException( string $type ): never
$type string

                protected function throwWrongTypeException(string $type): never
{
    throw new InvalidArgumentException("Wrong $type value for $this->type column.");
}

            
type() public method
public type( string $type ): Yiisoft\Db\Schema\Column\ArrayColumn
$type string

                public function type(string $type): static
{
    $this->type = $type;
    return $this;
}

            
unique() public method
public unique( boolean $unique true ): Yiisoft\Db\Schema\Column\ArrayColumn
$unique boolean

                public function unique(bool $unique = true): static
{
    $this->unique = $unique;
    return $this;
}

            
unsigned() public method
public unsigned( boolean $unsigned true ): Yiisoft\Db\Schema\Column\ArrayColumn
$unsigned boolean

                public function unsigned(bool $unsigned = true): static
{
    $this->unsigned = $unsigned;
    return $this;
}

            
withName() public method
public withName( string|null $name ): Yiisoft\Db\Schema\Column\ArrayColumn
$name string|null

                public function withName(?string $name): static
{
    $new = clone $this;
    $new->name = $name;
    return $new;
}