# HashCondition

> Condition based on column-value pairs.

[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) › HashCondition

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

Condition based on column-value pairs.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | HashCondition constructor. | `HashCondition` |
| [`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. | `HashCondition` |
| [`getHash()`](#method-getHash) |  | `HashCondition` |

## Method details

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

```php
public function __construct(array|null $hash)
```

HashCondition constructor.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$hash` | `array\|null` |  |

### 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**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): if input parameters are not suitable for this condition

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

```php
public function getHash(): array|null
```

**Returns**

`array|null`