InCondition
API reference › yii › db › conditions › InCondition
Represents IN condition.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | InCondition | |
fromArrayDefinition() static | Creates 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 |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(array|string|yii\db\ExpressionInterface|Traversable $column, string $operator, array|int|string|yii\db\ExpressionInterface|Traversable $values)Parameters
| Parameter | Type | Description |
|---|---|---|
$column | array|yii\|Traversable | The column name. If it is an array, a composite IN condition will be generated. |
$operator | string | The operator to use (e.g. IN or NOT IN). |
$values | array|yii\|Traversable | An 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. |
fromArrayDefinition()
Section titled “fromArrayDefinition() ”public static function fromArrayDefinition(mixed $operator, mixed $operands): staticCreates object by array-definition as described in Query Builder – Operator format guide article.
Parameters
| Parameter | Type | Description |
|---|---|---|
$operator | mixed | Operator in uppercase. |
$operands | mixed | Array of corresponding operands |
Returns
static
Throws
yii\base\InvalidArgumentException: if wrong number of operands have been given.
getColumn()
Section titled “getColumn() ”public function getColumn(): array|string|yii\db\ExpressionInterfaceReturns 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.
getOperator()
Section titled “getOperator() ”public function getOperator(): stringReturns the comparison operator.
Returns
string: Operator (for example, IN or NOT IN).
getValues()
Section titled “getValues() ”public function getValues(): array|int|string|yii\db\ExpressionInterfaceReturns 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.