Skip to content
PHP Ecosystem
Explore

InCondition

API reference › yii › db › conditions › InCondition

classyii\db\conditions\InCondition
ImplementsConditionInterface
Since2.0.14
Sourceframework/db/conditions/InCondition.php

Represents IN condition.

MethodDescriptionDefined by
__construct()InCondition
fromArrayDefinition() staticCreates object by array-definition as described in Query Builder – Operator format guide article.InCondition
getColumn()Returns the column(s) being matched.InCondition
getOperator()Returns the comparison operator.InCondition
getValues()Returns the value(s) to match against.InCondition
public function __construct(array|string|yii\db\ExpressionInterface|Traversable $column, string $operator, array|int|string|yii\db\ExpressionInterface|Traversable $values)

Parameters

ParameterTypeDescription
$columnarray|string|yii\db\ExpressionInterface|TraversableThe column name. If it is an array, a composite IN condition will be generated.
$operatorstringThe operator to use (e.g. IN or NOT IN).
$valuesarray|int|string|yii\db\ExpressionInterface|TraversableAn array of values that column value should be among. If it is an empty array the generated expression will be a false value if operator is IN and empty if operator is NOT IN.
public static function fromArrayDefinition(mixed $operator, mixed $operands): static

Creates object by array-definition as described in Query Builder – Operator format guide article.

Parameters

ParameterTypeDescription
$operatormixedOperator in uppercase.
$operandsmixedArray of corresponding operands

Returns

static

Throws

public function getColumn(): array|string|yii\db\ExpressionInterface

Returns the column(s) being matched.

Normalizes Traversable input to an array on first access and caches the result for subsequent calls.

Returns

array|string|yii\db\ExpressionInterface: Column name, list of column names for composite conditions, or an expression.

public function getOperator(): string

Returns the comparison operator.

Returns

string: Operator (for example, IN or NOT IN).

public function getValues(): array|int|string|yii\db\ExpressionInterface

Returns the value(s) to match against.

Normalizes Traversable input to an array on first access and caches the result for subsequent calls.

Returns

array|int|string|yii\db\ExpressionInterface: Value list, scalar, or expression used for the comparison.