Class yii\db\ArrayExpression

Inheritanceyii\db\ArrayExpression
ImplementsArrayAccess, Countable, IteratorAggregate, yii\db\ExpressionInterface
Available since version2.0.14
Source Code https://github.com/yiisoft/yii2/blob/master/framework/db/ArrayExpression.php

Class ArrayExpression represents an array SQL expression.

Expressions of this type can be used in conditions as well:

$query->andWhere(['@>', 'items', new ArrayExpression([1, 2, 3], 'integer')])

which, depending on DBMS, will result in a well-prepared condition. For example, in PostgreSQL it will be compiled to WHERE "items" @> ARRAY[1, 2, 3]::integer[].

Method Details

__construct() public method

ArrayExpression constructor.

public void __construct ( $value, $type null, $dimension 1 )
$value array|yii\db\QueryInterface|mixed

The array content. Either represented as an array of values or a Query that returns these values. A single value will be considered as an array containing one element.

$type string|null

The type of the array elements. Defaults to null which means the type is not explicitly specified. In case when type is not specified explicitly and DBMS can not guess it from the context, SQL error will be raised.

$dimension integer

The number of indices needed to select an element

count() public method

public void count ( )
getDimension() public method

public integer getDimension ( )
return integer

The number of indices needed to select an element

getIterator() public method

public void getIterator ( )
getType() public method

public string|null getType ( )
getValue() public method

public array|mixed|yii\db\QueryInterface getValue ( )
offsetExists() public method

public void offsetExists ( $offset )
$offset
offsetGet() public method

public void offsetGet ( $offset )
$offset
offsetSet() public method

public void offsetSet ( $offset, $value )
$offset
$value
offsetUnset() public method

public void offsetUnset ( $offset )
$offset