類別 yii\db\conditions\SimpleCondition
SimpleCondition 類別代表一個簡單的條件,例如 "column" 運算子 value
。
公開方法
方法詳情
SimpleCondition 建構子
public void __construct ( $column, $operator, $value ) | ||
$column | mixed |
$operator 左側的字面值 |
$operator | string |
要使用的運算子。可以使用任何符號,例如 |
$value | mixed |
$operator 右側的字面值 |
public function __construct($column, $operator, $value)
{
$this->column = $column;
$this->operator = $operator;
$this->value = $value;
}
依據陣列定義建立物件,如 查詢語法建構器 – 運算子格式 指南文章所述。
public static $this fromArrayDefinition ( $operator, $operands ) | ||
$operator | string |
大寫的運算子。 |
$operands | array |
對應運算元的陣列 |
throws | yii\base\InvalidArgumentException |
如果給定的運算元數量錯誤。 |
---|
public static function fromArrayDefinition($operator, $operands)
{
if (count($operands) !== 2) {
throw new InvalidArgumentException("Operator '$operator' requires two operands.");
}
return new static($operands[0], $operator, $operands[1]);
}
註冊 或 登入 以發表評論。