Final Class Yiisoft\Db\QueryBuilder\Condition\Like
| Inheritance | Yiisoft\Db\QueryBuilder\Condition\Like » Yiisoft\Db\QueryBuilder\Condition\AbstractLike |
|---|---|
| Implements | Yiisoft\Db\QueryBuilder\Condition\ConditionInterface |
Public Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $caseSensitive | boolean|null | Yiisoft\Db\QueryBuilder\Condition\AbstractLike | |
| $column | string|Yiisoft\Db\Expression\ExpressionInterface | Yiisoft\Db\QueryBuilder\Condition\AbstractLike | |
| $conjunction | \Yiisoft\Db\QueryBuilder\Condition\LikeConjunction | Yiisoft\Db\QueryBuilder\Condition\AbstractLike | |
| $escape | boolean | Yiisoft\Db\QueryBuilder\Condition\AbstractLike | |
| $mode | \Yiisoft\Db\QueryBuilder\Condition\LikeMode | Yiisoft\Db\QueryBuilder\Condition\AbstractLike | |
| $value | iterable|integer|string|\Stringable|Yiisoft\Db\Expression\ExpressionInterface|null | Yiisoft\Db\QueryBuilder\Condition\AbstractLike |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Db\QueryBuilder\Condition\AbstractLike | |
| fromArrayDefinition() | Creates a condition based on the given operator and operands. | Yiisoft\Db\QueryBuilder\Condition\AbstractLike |
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| DEFAULT_CONJUNCTION | \Yiisoft\Db\QueryBuilder\Condition\LikeConjunction::And | Yiisoft\Db\QueryBuilder\Condition\AbstractLike | |
| DEFAULT_ESCAPE | true | Yiisoft\Db\QueryBuilder\Condition\AbstractLike | |
| DEFAULT_MODE | \Yiisoft\Db\QueryBuilder\Condition\LikeMode::Contains | Yiisoft\Db\QueryBuilder\Condition\AbstractLike |
Method Details
| public mixed __construct ( Yiisoft\Db\Expression\ExpressionInterface|string $column, Yiisoft\Db\Expression\ExpressionInterface|integer|iterable|string|\Stringable|null $value, boolean|null $caseSensitive = null, boolean $escape = self::DEFAULT_ESCAPE, \Yiisoft\Db\QueryBuilder\Condition\LikeMode $mode = self::DEFAULT_MODE, \Yiisoft\Db\QueryBuilder\Condition\LikeConjunction $conjunction = self::DEFAULT_CONJUNCTION ) | ||
| $column | Yiisoft\Db\Expression\ExpressionInterface|string |
The column name. |
| $value | Yiisoft\Db\Expression\ExpressionInterface|integer|iterable|string|\Stringable|null |
The value to the right of operator. |
| $caseSensitive | boolean|null |
Whether the comparison is case-sensitive. |
| $escape | boolean |
Whether to escape the value. Defaults to |
| $mode | \Yiisoft\Db\QueryBuilder\Condition\LikeMode |
The mode for the LIKE operation (contains, starts with, ends with or custom pattern). |
| $conjunction | \Yiisoft\Db\QueryBuilder\Condition\LikeConjunction |
The conjunction to use for combining multiple LIKE conditions. |
final public function __construct(
public readonly string|ExpressionInterface $column,
public readonly iterable|int|string|Stringable|ExpressionInterface|null $value,
public readonly ?bool $caseSensitive = null,
public readonly bool $escape = self::DEFAULT_ESCAPE,
public readonly LikeMode $mode = self::DEFAULT_MODE,
public readonly LikeConjunction $conjunction = self::DEFAULT_CONJUNCTION,
) {}
Defined in: Yiisoft\Db\QueryBuilder\Condition\AbstractLike::fromArrayDefinition()
Creates a condition based on the given operator and operands.
| public static Yiisoft\Db\QueryBuilder\Condition\Like fromArrayDefinition ( string $operator, array $operands ) | ||
| $operator | string | |
| $operands | array | |
| throws | InvalidArgumentException |
If the number of operands isn't 2. |
|---|---|---|
final public static function fromArrayDefinition(string $operator, array $operands): static
{
if (!isset($operands[0], $operands[1])) {
throw new InvalidArgumentException("Operator '$operator' requires two operands.");
}
if (isset($operands['mode'])) {
$mode = $operands['mode'];
if (!$mode instanceof LikeMode) {
throw new InvalidArgumentException(
sprintf(
'Operator "%s" requires "mode" to be an instance of %s. Got %s.',
$operator,
LikeMode::class,
get_debug_type($mode),
),
);
}
} else {
$mode = self::DEFAULT_MODE;
}
if (isset($operands['conjunction'])) {
$conjunction = $operands['conjunction'];
if (!$conjunction instanceof LikeConjunction) {
throw new InvalidArgumentException(
sprintf(
'Operator "%s" requires "conjunction" to be an instance of %s. Got %s.',
$operator,
LikeConjunction::class,
get_debug_type($conjunction),
),
);
}
} else {
$conjunction = self::DEFAULT_CONJUNCTION;
}
return new static(
self::validateColumn($operator, $operands[0]),
self::validateValue($operator, $operands[1]),
isset($operands['caseSensitive']) ? (bool) $operands['caseSensitive'] : null,
isset($operands['escape']) ? (bool) $operands['escape'] : self::DEFAULT_ESCAPE,
$mode,
$conjunction,
);
}
Signup or Login in order to comment.