FOF30\Model\DataModel\Filter\Date::range PHP Метод

range() публичный Метод

Perform a between limits match. When $include is true the condition tested is: $from <= VALUE <= $to When $include is false the condition tested is: $from < VALUE < $to
public range ( mixed $from, mixed $to, boolean $include = true ) : string
$from mixed The lowest value to compare to
$to mixed The higherst value to compare to
$include boolean Should we include the boundaries in the search?
Результат string The SQL where clause for this search
    public function range($from, $to, $include = true)
    {
        if ($this->isEmpty($from) && $this->isEmpty($to)) {
            return '';
        }
        $extra = '';
        if ($include) {
            $extra = '=';
        }
        $sql = array();
        if ($from) {
            $sql[] = '(' . $this->getFieldName() . ' >' . $extra . ' ' . $this->db->q($from) . ')';
        }
        if ($to) {
            $sql[] = '(' . $this->getFieldName() . ' <' . $extra . ' ' . $this->db->q($to) . ')';
        }
        $sql = '(' . implode(' AND ', $sql) . ')';
        return $sql;
    }