Class yii\db\conditions\LikeCondition

Inheritanceyii\db\conditions\LikeCondition » yii\db\conditions\SimpleCondition
Implementsyii\db\conditions\ConditionInterface
Available since version2.0.14
Source Code https://github.com/yiisoft/yii2/blob/master/framework/db/conditions/LikeCondition.php

Class LikeCondition represents a LIKE condition.

Protected Properties

Hide inherited properties

Property Type Description Defined By

Property Details

Hide inherited properties

$escapingReplacements protected property

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.

Method Details

Hide inherited methods

__construct() public method

public void __construct ( $column, $operator, $value )
$column string

The column name.

$operator string

The operator to use (e.g. LIKE, NOT LIKE, OR LIKE or OR NOT LIKE)

$value string[]|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.

                public function __construct($column, $operator, $value)
{
    parent::__construct($column, $operator, $value);
}

            
fromArrayDefinition() public static method

Creates object by array-definition as described in Query Builder – Operator format guide article.

public static $this fromArrayDefinition ( $operator, $operands )
$operator string

Operator in uppercase.

$operands array

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;
}

            
getColumn() public method
public mixed getColumn ( )

                public function getColumn()
{
    return $this->column;
}

            
getEscapingReplacements() public method

public array|null|false getEscapingReplacements ( )

                public function getEscapingReplacements()
{
    return $this->escapingReplacements;
}

            
getOperator() public method
public string getOperator ( )

                public function getOperator()
{
    return $this->operator;
}

            
getValue() public method
public mixed getValue ( )

                public function getValue()
{
    return $this->value;
}

            
setEscapingReplacements() public method

This method allows to specify how to escape special characters in the value(s).

public void setEscapingReplacements ( $escapingReplacements )
$escapingReplacements

                public function setEscapingReplacements($escapingReplacements)
{
    $this->escapingReplacements = $escapingReplacements;
}