mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-15 22:16:32 +02:00
8dd644d25d
Namespace all templates Move difflib and BBCodeParser2 to thirdparty Remove deprecated API marked for removal in 4.0
47 lines
872 B
PHP
47 lines
872 B
PHP
<?php
|
|
|
|
namespace SilverStripe\ORM\Filters;
|
|
|
|
use SilverStripe\ORM\DataQuery;
|
|
|
|
/**
|
|
* Incomplete.
|
|
*
|
|
* @todo add to tests
|
|
*/
|
|
class WithinRangeFilter extends SearchFilter {
|
|
|
|
private $min;
|
|
private $max;
|
|
|
|
public function setMin($min) {
|
|
$this->min = $min;
|
|
}
|
|
|
|
public function setMax($max) {
|
|
$this->max = $max;
|
|
}
|
|
|
|
protected function applyOne(DataQuery $query) {
|
|
$this->model = $query->applyRelation($this->relation);
|
|
$predicate = sprintf('%1$s >= ? AND %1$s <= ?', $this->getDbName());
|
|
return $query->where(array(
|
|
$predicate => array(
|
|
$this->min,
|
|
$this->max
|
|
)
|
|
));
|
|
}
|
|
|
|
protected function excludeOne(DataQuery $query) {
|
|
$this->model = $query->applyRelation($this->relation);
|
|
$predicate = sprintf('%1$s < ? OR %1$s > ?', $this->getDbName());
|
|
return $query->where(array(
|
|
$predicate => array(
|
|
$this->min,
|
|
$this->max
|
|
)
|
|
));
|
|
}
|
|
}
|