mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-19 07:56:38 +02:00
d370423825
All sapphire but the lang directory
29 lines
685 B
PHP
29 lines
685 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() == '';
|
|
}
|
|
}
|