Class yii\db\conditions\BetweenColumnsCondition
继承 | yii\db\conditions\BetweenColumnsCondition |
---|---|
实现 | yii\db\conditions\ConditionInterface |
可用版本自 | 2.0.14 |
源码 | https://github.com/yiichina/yii2/blob/api/framework/db/conditions/BetweenColumnsCondition.php |
BetweenColumnCondition 类表示 BETWEEN
条件
其中值在两个列中间。比如:
new BetweenColumnsCondition(42, 'BETWEEN', 'min_value', 'max_value')
// Will be built 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
公共方法
方法详情
使用 BETWEEN
运算符创建条件
public void __construct($value, $operator, $intervalStartColumn, $intervalEndColumn) | ||
$value | ||
$operator | string | 要使用的运算符(例如: |
$intervalStartColumn | string|yii\db\ExpressionInterface | 作为间隔开头的列名称或表达式 |
$intervalEndColumn | string|yii\db\ExpressionInterface | 作为间隔结尾的列名称或表达式 |
按照 文档:查询构建器 - 操作符格式 文档中的描述, 以数组定义创建对象。
public static $this fromArrayDefinition($operator, $operands) | ||
$operator | string | 操作符大写。 |
$operands | array | 相应操作数的数组。 |
throws | yii\base\InvalidArgumentException | 如果已给出错误的操作数,则抛出 InvalidArgumentException 异常。 |
---|
public string|yii\db\ExpressionInterface|yii\db\Query getIntervalEndColumn() |
public string|yii\db\ExpressionInterface|yii\db\Query getIntervalStartColumn() |
public string getOperator() |
public mixed getValue() |