1 关注者

类 yii\db\conditions\BetweenColumnsCondition

继承yii\db\conditions\BetweenColumnsCondition
实现yii\db\conditions\ConditionInterface
自版本可用2.0.14
源代码 https://github.com/yiisoft/yii2/blob/master/framework/db/conditions/BetweenColumnsCondition.php

类 BetweenColumnCondition 表示一个 BETWEEN 条件,其中值介于两个列之间。例如

new BetweenColumnsCondition(42, 'BETWEEN', 'min_value', 'max_value')
// Will be build to:
// 42 BETWEEN min_value AND max_value

更复杂的示例

new BetweenColumnsCondition(
   new Expression('NOW()'),
   'NOT BETWEEN',
   (new Query)->select('time')->from('log')->orderBy('id ASC')->limit(1),
   'update_time'
);

// Will be built to:
// NOW() NOT BETWEEN (SELECT time FROM log ORDER BY id ASC LIMIT 1) AND update_time

方法详情

隐藏继承的方法

__construct() 公共方法

使用 BETWEEN 运算符创建条件。

public void __construct ( $value, $operator, $intervalStartColumn, $intervalEndColumn )
$value
$operator string

要使用的运算符(例如 BETWEENNOT BETWEEN

$intervalStartColumn string|yii\db\ExpressionInterface

作为间隔开头的列名或表达式

$intervalEndColumn string|yii\db\ExpressionInterface

作为间隔结束的列名或表达式

                public function __construct($value, $operator, $intervalStartColumn, $intervalEndColumn)
{
    $this->value = $value;
    $this->operator = $operator;
    $this->intervalStartColumn = $intervalStartColumn;
    $this->intervalEndColumn = $intervalEndColumn;
}

            
fromArrayDefinition() 公共静态方法

使用数组定义创建对象,如 查询构建器 - 运算符格式 指南文章中所述。

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

大写运算符。

$operands array

对应操作数的数组

抛出 yii\base\InvalidArgumentException

如果提供了错误数量的操作数。

                public static function fromArrayDefinition($operator, $operands)
{
    if (!isset($operands[0], $operands[1], $operands[2])) {
        throw new InvalidArgumentException("Operator '$operator' requires three operands.");
    }
    return new static($operands[0], $operator, $operands[1], $operands[2]);
}

            
getIntervalEndColumn() 公共方法

public string|yii\db\ExpressionInterface|yii\db\Query getIntervalEndColumn ( )

                public function getIntervalEndColumn()
{
    return $this->intervalEndColumn;
}

            
getIntervalStartColumn() 公共方法

public string|yii\db\ExpressionInterface|yii\db\Query getIntervalStartColumn ( )

                public function getIntervalStartColumn()
{
    return $this->intervalStartColumn;
}

            
getOperator() 公共方法

public string getOperator ( )

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

            
getValue() 公共方法

public mixed getValue ( )

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