2008-08-11 02:03:57 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Selects numerical/date content smaller than the input
|
|
|
|
*
|
|
|
|
* @todo documentation
|
|
|
|
*
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2008-08-11 02:03:57 +02:00
|
|
|
* @subpackage search
|
|
|
|
*/
|
|
|
|
class LessThanFilter extends SearchFilter {
|
|
|
|
|
|
|
|
/**
|
2012-09-06 09:54:44 +02:00
|
|
|
* @return DataQuery
|
2008-08-11 02:03:57 +02:00
|
|
|
*/
|
2012-09-06 09:54:44 +02:00
|
|
|
protected function applyOne(DataQuery $query) {
|
2011-03-21 09:37:55 +01:00
|
|
|
$this->model = $query->applyRelation($this->relation);
|
2011-12-17 04:32:45 +01:00
|
|
|
$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);
|
2008-08-11 02:03:57 +02:00
|
|
|
}
|
2012-09-06 09:54:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return DataQuery
|
|
|
|
*/
|
|
|
|
protected function excludeOne(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);
|
|
|
|
}
|
2008-08-11 02:03:57 +02:00
|
|
|
|
|
|
|
public function isEmpty() {
|
2012-09-06 09:54:44 +02:00
|
|
|
return $this->getValue() === array() || $this->getValue() === null || $this->getValue() === '';
|
2008-08-11 02:03:57 +02:00
|
|
|
}
|
|
|
|
}
|