Class yii\db\conditions\InCondition
| Inheritance | yii\ |
|---|---|
| Implements | yii\ |
| Available since version | 2.0.14 |
| Source Code | https://github.com/yiisoft/yii2/blob/master/framework/db/conditions/InCondition.php |
Represents IN condition.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | yii\ |
|
| fromArrayDefinition() | Creates object by array-definition as described in Query Builder – Operator format guide article. | yii\ |
| getColumn() | Returns the column(s) being matched. | yii\ |
| getOperator() | Returns the comparison operator. | yii\ |
| getValues() | Returns the value(s) to match against. | yii\ |
Method Details
| public mixed __construct ( array|string|yii\ | ||
| $column | array|string|yii\ |
The column name. If it is an array, a composite |
| $operator | string |
The operator to use (e.g. |
| $values | array|integer|string|yii\ |
An array of values that column value should
be among. If it is an empty array the generated expression will be a |
public function __construct(
private array|string|ExpressionInterface|Traversable $column,
private string $operator,
private array|int|string|ExpressionInterface|Traversable $values
) {
}
Creates object by array-definition as described in Query Builder – Operator format guide article.
| public static static fromArrayDefinition ( mixed $operator, mixed $operands ) | ||
| $operator | mixed |
Operator in uppercase. |
| $operands | mixed |
Array of corresponding operands |
| throws | yii\ |
if wrong number of operands have been given. |
|---|---|---|
public static function fromArrayDefinition($operator, $operands): static
{
if (!isset($operands[0], $operands[1])) {
throw new InvalidArgumentException("Operator '$operator' requires two operands.");
}
return new static($operands[0], $operator, $operands[1]);
}
Returns the column(s) being matched.
Normalizes Traversable input to an array on first access and caches the result for subsequent calls.
| public array|string|yii\ | ||
| return | array|string|yii\ |
Column name, list of column names for composite conditions, or an expression. |
|---|---|---|
public function getColumn(): array|string|ExpressionInterface
{
if ($this->column instanceof Traversable && !$this->column instanceof ExpressionInterface) {
$this->column = iterator_to_array($this->column);
}
return $this->column;
}
Returns the comparison operator.
| public string getOperator ( ) | ||
| return | string |
Operator (for example, |
|---|---|---|
public function getOperator(): string
{
return $this->operator;
}
Returns the value(s) to match against.
Normalizes Traversable input to an array on first access and caches the result for subsequent calls.
| public array|integer|string|yii\ | ||
| return | array|integer|string|yii\ |
Value list, scalar, or expression used for the comparison. |
|---|---|---|
public function getValues(): array|int|string|ExpressionInterface
{
if ($this->values instanceof Traversable && !$this->values instanceof ExpressionInterface) {
$this->values = iterator_to_array($this->values);
}
return $this->values;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.