Final Class Yiisoft\Db\Expression\Value\ArrayValue
| Inheritance | Yiisoft\Db\Expression\Value\ArrayValue |
|---|---|
| Implements | Yiisoft\Db\Expression\ExpressionInterface |
Represents an array SQL expression.
Expressions of this type can be used in conditions as well:
$query->andWhere(['@>', 'items', new ArrayValue([1, 2, 3], 'integer[]')]);
Which, depending on DBMS, will result in a well-prepared condition. For example, in PostgresSQL it will be compiled
to WHERE "items" @> ARRAY[1, 2, 3]::integer[].
Public Properties
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Db\Expression\Value\ArrayValue |
Property Details
Method Details
| public mixed __construct ( iterable|Yiisoft\Db\Schema\Data\LazyArrayInterface|Yiisoft\Db\Query\QueryInterface|string|null $value, Yiisoft\Db\Schema\Column\ColumnInterface|string|null $type = null ) | ||
| $value | iterable|Yiisoft\Db\Schema\Data\LazyArrayInterface|Yiisoft\Db\Query\QueryInterface|string|null |
The array value which can be represented as
|
| $type | Yiisoft\Db\Schema\Column\ColumnInterface|string|null |
The array column type which can be represented as
String type will be converted into {@see \Yiisoft\Db\Schema\Column\ColumnInterface} using {@see \Yiisoft\Db\Schema\Column\ColumnFactoryInterface::fromDefinition()}.
The column type is used to typecast array values before saving into the database and for adding type hint to
the SQL statement. If the type isn't specified and DBMS can't guess it from the context, SQL error will be raised.
The {@see \Yiisoft\Db\QueryBuilder\ColumnDefinitionBuilderInterface::buildType()} method will be invoked to convert {@see \Yiisoft\Db\Schema\Column\ColumnInterface}
into SQL representation. For example, it will convert |
public function __construct(
public readonly iterable|LazyArrayInterface|QueryInterface|string|null $value,
public readonly ColumnInterface|string|null $type = null,
) {}
Signup or Login in order to comment.