# InCondition

> Represents IN condition.

[API reference](/docs/api/index.md) › [yii](/docs/api/yii/index.md) › [db](/docs/api/yii/db/index.md) › [conditions](/docs/api/yii/db/conditions/index.md) › InCondition

| class | `yii\db\conditions\InCondition` |
| --- | --- |
| Implements | [`ConditionInterface`](/docs/api/yii/db/conditions/conditioninterface/index.md) |
| Since | 2.0.14 |
| Source | [`framework/db/conditions/InCondition.php`](https://github.com/yiisoft/yii2/blob/22.0/framework/db/conditions/InCondition.php#L23) |

Represents `IN` condition.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) |  | `InCondition` |
| [`fromArrayDefinition()`](#method-fromArrayDefinition) static | Creates object by array-definition as described in [Query Builder – Operator format](/docs/guide/db-query-builder/index.md#operator-format) guide article. | `InCondition` |
| [`getColumn()`](#method-getColumn) | Returns the column(s) being matched. | `InCondition` |
| [`getOperator()`](#method-getOperator) | Returns the comparison operator. | `InCondition` |
| [`getValues()`](#method-getValues) | Returns the value(s) to match against. | `InCondition` |

## Method details

### __construct() <span id="method-__construct"></span>

```php
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\|string\|`[`yii\db\ExpressionInterface`](/docs/api/yii/db/expressioninterface/index.md)`\|`[`Traversable`](https://www.php.net/manual/en/class.traversable.php) | 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\|int\|string\|`[`yii\db\ExpressionInterface`](/docs/api/yii/db/expressioninterface/index.md)`\|`[`Traversable`](https://www.php.net/manual/en/class.traversable.php) | 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() <span id="method-fromArrayDefinition"></span>

```php
public static function fromArrayDefinition(mixed $operator, mixed $operands): static
```

Creates object by array-definition as described in
[Query Builder – Operator format](/docs/guide/db-query-builder/index.md#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`](/docs/api/yii/base/invalidargumentexception/index.md): if wrong number of operands have been given.

### getColumn() <span id="method-getColumn"></span>

```php
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`](/docs/api/yii/db/expressioninterface/index.md): Column name, list of column names for composite conditions, or an expression.

### getOperator() <span id="method-getOperator"></span>

```php
public function getOperator(): string
```

Returns the comparison operator.

**Returns**

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

### getValues() <span id="method-getValues"></span>

```php
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`](/docs/api/yii/db/expressioninterface/index.md): Value list, scalar, or expression used for the comparison.