0 關注者

Class yii\db\conditions\LikeCondition

繼承yii\db\conditions\LikeCondition » yii\db\conditions\SimpleCondition
實作yii\db\conditions\ConditionInterface
自版本起可用2.0.14
原始碼 https://github.com/yiisoft/yii2/blob/master/framework/db/conditions/LikeCondition.php

LikeCondition 類別代表一個 LIKE 條件。

受保護的屬性

隱藏繼承的屬性

屬性 類型 描述 定義於

屬性詳細資訊

隱藏繼承的屬性

$escapingReplacements 受保護的屬性

字元到其替換字元的映射,如果字元不應被跳脫則為 false,如果跳脫是條件建構器的責任,則為 null 或空陣列。預設設定為 null。

方法詳細資訊

隱藏繼承的方法

__construct() 公共方法

public void __construct ( $column, $operator, $value )
$column 字串

欄位名稱。

$operator 字串

要使用的運算子 (例如 LIKENOT LIKEOR LIKEOR NOT LIKE)

$value 字串[]|字串

單一值或一個數值陣列,用於與 $column 進行比較。如果它是一個空陣列,當運算子為 LIKEOR LIKE 時,產生的表達式將為 false 值,而當運算子為 NOT LIKEOR NOT LIKE 時則為空。

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

            
fromArrayDefinition() public static method

依照 查詢語法建構器 – 運算符格式 指南文章中描述的陣列定義建立物件。

public static $this fromArrayDefinition ( $operator, $operands )
$operator 字串

大寫的運算子。

$operands 陣列

對應運算元的陣列

拋出 yii\base\InvalidArgumentException

如果給出的運算元數量錯誤。

                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 字串 getOperator ( )

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

            
getValue() public method
public mixed getValue ( )

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

            
setEscapingReplacements() public method

此方法允許指定如何跳脫值中的特殊字元。

public void setEscapingReplacements ( $escapingReplacements )
$escapingReplacements

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