function NumericFilter::opBetween
Same name in other branches
- 9 core/modules/views/src/Plugin/views/filter/NumericFilter.php \Drupal\views\Plugin\views\filter\NumericFilter::opBetween()
- 8.9.x core/modules/views/src/Plugin/views/filter/NumericFilter.php \Drupal\views\Plugin\views\filter\NumericFilter::opBetween()
- 10 core/modules/views/src/Plugin/views/filter/NumericFilter.php \Drupal\views\Plugin\views\filter\NumericFilter::opBetween()
Filters by operator between.
Parameters
object $field: The views field.
2 methods override NumericFilter::opBetween()
- Date::opBetween in core/
modules/ views/ src/ Plugin/ views/ filter/ Date.php - Filters by operator between.
- GroupByNumeric::opBetween in core/
modules/ views/ src/ Plugin/ views/ filter/ GroupByNumeric.php - Filters by operator between.
File
-
core/
modules/ views/ src/ Plugin/ views/ filter/ NumericFilter.php, line 349
Class
- NumericFilter
- Simple filter to handle greater than/less than filters.
Namespace
Drupal\views\Plugin\views\filterCode
protected function opBetween($field) {
if (is_numeric($this->value['min']) && is_numeric($this->value['max'])) {
$operator = $this->operator == 'between' ? 'BETWEEN' : 'NOT BETWEEN';
$this->query
->addWhere($this->options['group'], $field, [
$this->value['min'],
$this->value['max'],
], $operator);
}
elseif (is_numeric($this->value['min'])) {
$operator = $this->operator == 'between' ? '>=' : '<';
$this->query
->addWhere($this->options['group'], $field, $this->value['min'], $operator);
}
elseif (is_numeric($this->value['max'])) {
$operator = $this->operator == 'between' ? '<=' : '>';
$this->query
->addWhere($this->options['group'], $field, $this->value['max'], $operator);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.