Class yii\db\conditions\BetweenColumnsCondition
Inheritance | yii\db\conditions\BetweenColumnsCondition |
---|---|
Implements | yii\db\conditions\ConditionInterface |
Available since version | 2.0.14 |
Source Code | https://github.com/yiisoft/yii2/blob/master/framework/db/conditions/BetweenColumnsCondition.php |
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()'),
'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
Public Methods
Method | Description | Defined By |
---|---|---|
__construct() | Creates a condition with the BETWEEN operator. |
yii\db\conditions\BetweenColumnsCondition |
fromArrayDefinition() | Creates object by array-definition as described in Query Builder – Operator format guide article. | yii\db\conditions\BetweenColumnsCondition |
getIntervalEndColumn() | yii\db\conditions\BetweenColumnsCondition | |
getIntervalStartColumn() | yii\db\conditions\BetweenColumnsCondition | |
getOperator() | yii\db\conditions\BetweenColumnsCondition | |
getValue() | yii\db\conditions\BetweenColumnsCondition |
Method Details
Creates a condition with the BETWEEN
operator.
public void __construct ( $value, $operator, $intervalStartColumn, $intervalEndColumn ) | ||
$value | ||
$operator | string |
The operator to use (e.g. |
$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 |
public function __construct($value, $operator, $intervalStartColumn, $intervalEndColumn)
{
$this->value = $value;
$this->operator = $operator;
$this->intervalStartColumn = $intervalStartColumn;
$this->intervalEndColumn = $intervalEndColumn;
}
Creates object by array-definition as described in Query Builder – Operator format guide article.
public static $this fromArrayDefinition ( $operator, $operands ) | ||
$operator | string |
Operator in uppercase. |
$operands | array |
Array of corresponding operands |
throws | yii\base\InvalidArgumentException |
if wrong number of operands have been given. |
---|
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]);
}
public string|yii\db\ExpressionInterface|yii\db\Query getIntervalEndColumn ( ) |
public function getIntervalEndColumn()
{
return $this->intervalEndColumn;
}
public string|yii\db\ExpressionInterface|yii\db\Query getIntervalStartColumn ( ) |
public function getIntervalStartColumn()
{
return $this->intervalStartColumn;
}
Signup or Login in order to comment.