HumHub Documentation (unofficial)

ArrayExpression
in package
implements ExpressionInterface, ArrayAccess, Countable, IteratorAggregate

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[].

Tags
author

Dmytro Naumenko d.naumenko.a@gmail.com

since
2.0.14
phpcs:disable

Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore

Table of Contents

Interfaces

ExpressionInterface
Interface ExpressionInterface should be used to mark classes, that should be built in a special way.
ArrayAccess
Countable
IteratorAggregate

Properties

$dimension  : int
$type  : string|null
$value  : array<string|int, mixed>|QueryInterface

Methods

__construct()  : mixed
ArrayExpression constructor.
count()  : int
Count elements of an object
getDimension()  : int
getIterator()  : Traversable
Retrieve an external iterator
getType()  : string|null
getValue()  : array<string|int, mixed>|mixed|QueryInterface
offsetExists()  : bool
Whether a offset exists
offsetGet()  : mixed
Offset to retrieve
offsetSet()  : void
Offset to set
offsetUnset()  : void
Offset to unset

Properties

$dimension

private int $dimension

the number of indices needed to select an element

$type

private string|null $type

the type of the array elements. Defaults to null which means the type is not explicitly specified.

Note that in case when type is not specified explicitly and DBMS can not guess it from the context, SQL error will be raised.

$value

private array<string|int, mixed>|QueryInterface $value

the array's content. In can be represented as an array of values or a [[Query]] that returns these values.

Methods

__construct()

ArrayExpression constructor.

public __construct(array<string|int, mixed>|QueryInterface|mixed $value[, string|null $type = null ][, int $dimension = 1 ]) : mixed
Parameters
$value : array<string|int, mixed>|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 = 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 : int = 1

the number of indices needed to select an element

getDimension()

public getDimension() : int
Return values
int

the number of indices needed to select an element


        
On this page

Search results