mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-08-26 04:26:01 +02:00
29 lines
687 B
PHP
29 lines
687 B
PHP
<?php
|
|
/**
|
|
* Selects numerical/date content smaller than the input
|
|
*
|
|
* @todo documentation
|
|
*
|
|
* @package sapphire
|
|
* @subpackage search
|
|
*/
|
|
class LessThanFilter extends SearchFilter {
|
|
|
|
/**
|
|
* @return $query
|
|
*/
|
|
public function apply(DataQuery $query) {
|
|
$this->model = $query->applyRelation($this->relation);
|
|
$value = $this->getDbFormattedValue();
|
|
|
|
if(is_numeric($value)) $filter = sprintf("%s < %s", $this->getDbName(), Convert::raw2sql($value));
|
|
else $filter = sprintf("%s < '%s'", $this->getDbName(), Convert::raw2sql($value));
|
|
|
|
return $query->where($filter);
|
|
}
|
|
|
|
public function isEmpty() {
|
|
return $this->getValue() == null || $this->getValue() == '';
|
|
}
|
|
}
|
|
?>
|