LikeCondition
API reference › yii › db › conditions › LikeCondition
Class LikeCondition represents a LIKE condition.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$escapingReplacements protected | array| | 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. Default: null. | LikeCondition |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | LikeCondition | |
fromArrayDefinition() static | Creates object by array-definition as described in Query Builder – Operator format guide article. | LikeCondition |
getColumn() | SimpleCondition | |
getEscapingReplacements() | LikeCondition | |
getOperator() | SimpleCondition | |
getValue() | SimpleCondition | |
setEscapingReplacements() | This method allows to specify how to escape special characters in the value(s). | LikeCondition |
Property details
Section titled “Property details”$escapingReplacements
Section titled “$escapingReplacements ”protected array|null|false $escapingReplacements = nullMap 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.
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(string $column, string $operator, string[]|string $value)Parameters
| Parameter | Type | Description |
|---|---|---|
$column | string | The column name. |
$operator | string | The operator to use (e.g. LIKE, NOT LIKE, OR LIKE or OR NOT LIKE) |
$value | string[]| | 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. |
fromArrayDefinition()
Section titled “fromArrayDefinition() ”public static function fromArrayDefinition(mixed $operator, mixed $operands): staticCreates object by array-definition as described in Query Builder – 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: if wrong number of operands have been given.
getEscapingReplacements()
Section titled “getEscapingReplacements() ”public function getEscapingReplacements(): array|null|falseReturns
array|null|false
setEscapingReplacements()
Section titled “setEscapingReplacements() ”public function setEscapingReplacements(array|null|false $escapingReplacements): mixedThis method allows to specify how to escape special characters in the value(s).
Parameters
| Parameter | Type | Description |
|---|---|---|
$escapingReplacements | array| | 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. |
Returns
mixed