mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-19 16:06:32 +02:00
41 lines
642 B
PHP
41 lines
642 B
PHP
<?php
|
|
/**
|
|
* @package framework
|
|
* @subpackage search
|
|
*/
|
|
|
|
/**
|
|
* Incomplete.
|
|
*
|
|
* @todo add to tests
|
|
*
|
|
* @package framework
|
|
* @subpackage search
|
|
*/
|
|
class WithinRangeFilter extends SearchFilter {
|
|
|
|
private $min;
|
|
private $max;
|
|
|
|
public function setMin($min) {
|
|
$this->min = $min;
|
|
}
|
|
|
|
public function setMax($max) {
|
|
$this->max = $max;
|
|
}
|
|
|
|
public function apply(DataQuery $query) {
|
|
$this->model = $query->applyRelation($this->relation);
|
|
return $query->where(sprintf(
|
|
"%s >= '%s' AND %s <= '%s'",
|
|
$this->getDbName(),
|
|
Convert::raw2sql($this->min),
|
|
$this->getDbName(),
|
|
Convert::raw2sql($this->max)
|
|
));
|
|
}
|
|
|
|
}
|
|
|