Class yii\db\conditions\BetweenColumnsCondition

Available since version2.0.14
Source Code

Class BetweenColumnCondition represents a BETWEEN condition where values is between two columns. For example:

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

And a more complex example:

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

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

Method Details

__construct() public method

Creates a condition with the BETWEEN operator.

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

The operator to use (e.g. BETWEEN or NOT BETWEEN)

$intervalStartColumn string|yii\db\ExpressionInterface

The column name or expression that is a beginning of the interval

$intervalEndColumn string|yii\db\ExpressionInterface

The column name or expression that is an end of the interval

fromArrayDefinition() public static method


public static void fromArrayDefinition ( $operator, $operands )
throws yii\base\InvalidArgumentException

if wrong number of operands have been given.

getIntervalEndColumn() public method

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

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

public string getOperator ( )
getValue() public method

public mixed getValue ( )