| Inheritance | yii\db\conditions\LikeCondition » yii\db\conditions\SimpleCondition |
|---|---|
| Implements | yii\db\conditions\ConditionInterface |
| Available since version | 2.0.14 |
| Source Code | https://github.com/yiisoft/yii2/blob/master/framework/db/conditions/LikeCondition.php |
Class LikeCondition represents a LIKE condition.
| Property | Type | Description | Defined By |
|---|---|---|---|
| $escapingReplacements | array|null|false | Map of chars to their replacements, false if characters should not be escaped or either null or empty array if escaping is condition builder responsibility. |
yii\db\conditions\LikeCondition |
| Method | Description | Defined By |
|---|---|---|
| __construct() | yii\db\conditions\LikeCondition | |
| fromArrayDefinition() | Creates object by array-definition as described in Query Builder – Operator format guide article. | yii\db\conditions\LikeCondition |
| getColumn() | yii\db\conditions\SimpleCondition | |
| getEscapingReplacements() | yii\db\conditions\LikeCondition | |
| getOperator() | yii\db\conditions\SimpleCondition | |
| getValue() | yii\db\conditions\SimpleCondition | |
| setEscapingReplacements() | This method allows to specify how to escape special characters in the value(s). | yii\db\conditions\LikeCondition |
Map of chars to their replacements, false if characters should not be escaped
or either null or empty array if escaping is condition builder responsibility.
By default it's set to null.
Single value or an array of values that $column should be compared with.
If it is an empty array the generated expression will be a false value if operator is LIKE or OR LIKE
and empty if operator is NOT LIKE or OR NOT LIKE.
public function __construct($column, $operator, $value)
{
parent::__construct($column, $operator, $value);
}
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\base\InvalidArgumentException |
if wrong number of operands have been given. |
|---|---|---|
public static function fromArrayDefinition($operator, $operands)
{
if (!isset($operands[0], $operands[1])) {
throw new InvalidArgumentException("Operator '$operator' requires two operands.");
}
$condition = new static($operands[0], $operator, $operands[1]);
if (isset($operands[2])) {
$condition->escapingReplacements = $operands[2];
}
return $condition;
}
Defined in: yii\db\conditions\SimpleCondition::getColumn()
public function getColumn()
{
return $this->column;
}
public function getEscapingReplacements()
{
return $this->escapingReplacements;
}
Defined in: yii\db\conditions\SimpleCondition::getOperator()
public function getOperator()
{
return $this->operator;
}
Defined in: yii\db\conditions\SimpleCondition::getValue()
public function getValue()
{
return $this->value;
}
This method allows to specify how to escape special characters in the value(s).
An array of mappings from the special characters to their escaped counterparts.
You may use false to indicate the values are already escaped and no escape should be applied,
or either null or empty array if escaping is condition builder responsibility.
Note that when using an escape mapping (or the third operand is not provided),
the values will be automatically enclosed within a pair of percentage characters.
public function setEscapingReplacements($escapingReplacements)
{
$this->escapingReplacements = $escapingReplacements;
}