private function _applyFilters(\Mmi\Orm\Query $query)
    {
        //iteracja po filtrach
        foreach ($this->getFilters() as $filter) {
            //filtr nie jest prawidłowy
            if (!($filter instanceof GridStateFilter)) {
                throw new GridException('Invalid state filter object');
            }
            //operator równości
            if ($filter->getMethod() == 'equals') {
                $query->andField($filter->getField(), $filter->getTableName())->equals($filter->getValue());
                continue;
            }
            //podobieństwo
            if ($filter->getMethod() == 'like') {
                $query->andField($filter->getField(), $filter->getTableName())->like($filter->getValue() . '%');
                continue;
            }
            //większość
            if ($filter->getMethod() == 'null') {
                if ($filter->getValue()) {
                    $query->andField($filter->getField(), $filter->getTableName())->notEquals(null);
                    continue;
                }
                $query->andField($filter->getField(), $filter->getTableName())->equals(null);
                continue;
            }
            if ($filter->getMethod() == 'between') {
                $range = explode(';', $filter->getValue());
                //zdefiniowane od
                if (!empty($range[0])) {
                    $query->andField($filter->getField(), $filter->getTableName())->greaterOrEquals($range[0]);
                }
                //zdefiniowane do
                if (isset($range[1]) && !empty($range[1])) {
                    $query->andField($filter->getField(), $filter->getTableName())->lessOrEquals($range[1]);
                }
                continue;
            }
            //domyślnie - wyszukanie
            $query->andField($filter->getField(), $filter->getTableName())->like('%' . $filter->getValue() . '%');
        }
        return $this;
    }
private function _applyFilters(\Mmi\Orm\Query $query)
    {
        //iteracja po filtrach
        foreach ($this->getFilters() as $filter) {
            //filtr nie jest prawidłowy
            if (!($filter instanceof GridStateFilter)) {
                throw new GridException('Invalid state filter object');
            }
            //operator równości
            if ($filter->getMethod() == 'equals') {
                $query->andField($filter->getField(), $filter->getTableName())->equals($filter->getValue());
                continue;
            }
            //podobieństwo
            if ($filter->getMethod() == 'like') {
                $query->andField($filter->getField(), $filter->getTableName())->like($filter->getValue() . '%');
                continue;
            }
            //większość
            if ($filter->getMethod() == 'null') {
                if ($filter->getValue()) {
                    $query->andField($filter->getField(), $filter->getTableName())->notEquals(null);
                    continue;
                }
                $query->andField($filter->getField(), $filter->getTableName())->equals(null);
                continue;
            }
            if ($filter->getMethod() == 'between') {
                $range = explode(';', $filter->getValue());
                //zdefiniowane od
                if (!empty($range[0])) {
                    $query->andField($filter->getField(), $filter->getTableName())->greaterOrEquals($range[0]);
                }
                //zdefiniowane do
                if (isset($range[1]) && !empty($range[1])) {
                    $query->andField($filter->getField(), $filter->getTableName())->lessOrEquals($range[1]);
                }
                continue;
            }
            //domyślnie - wyszukanie
            $query->andField($filter->getField(), $filter->getTableName())->like('%' . $filter->getValue() . '%');
        }
        return $this;
    }
private function _applyFilters ( \ Mmi \ Orm \ Query $ query ) { //iteracja po filtrach foreach ( $ this -> getFilters ( ) as $ filter ) { //filtr nie jest prawidłowy if ( ! ( $ filter instanceof GridStateFilter ) ) { throw new GridException ( 'Invalid state filter object' ) ; } //operator równości if ( $ filter -> getMethod ( ) == 'equals' ) { $ query -> andField ( $ filter -> getField ( ) , $ filter -> getTableName ( ) ) -> equals ( $ filter -> getValue ( ) ) ; continue ; } //podobieństwo if ( $ filter -> getMethod ( ) == 'like' ) { $ query -> andField ( $ filter -> getField ( ) , $ filter -> getTableName ( ) ) -> like ( $ filter -> getValue ( ) . '%' ) ; continue ; } //większość if ( $ filter -> getMethod ( ) == 'null' ) { if ( $ filter -> getValue ( ) ) { $ query -> andField ( $ filter -> getField ( ) , $ filter -> getTableName ( ) ) -> notEquals ( null ) ; continue ; } $ query -> andField ( $ filter -> getField ( ) , $ filter -> getTableName ( ) ) -> equals ( null ) ; continue ; } if ( $ filter -> getMethod ( ) == 'between' ) { $ range = explode ( ';' , $ filter -> getValue ( ) ) ; //zdefiniowane od if ( ! empty ( $ range [ 0 ] ) ) { $ query -> andField ( $ filter -> getField ( ) , $ filter -> getTableName ( ) ) -> greaterOrEquals ( $ range [ 0 ] ) ; } //zdefiniowane do if ( isset ( $ range [ 1 ] ) && ! empty ( $ range [ 1 ] ) ) { $ query -> andField ( $ filter -> getField ( ) , $ filter -> getTableName ( ) ) -> lessOrEquals ( $ range [ 1 ] ) ; } continue ; } //domyślnie - wyszukanie $ query -> andField ( $ filter -> getField ( ) , $ filter -> getTableName ( ) ) -> like ( '%' . $ filter -> getValue ( ) . '%' ) ; } return $ this ; }
Stosuje filtry na zapytaniu
@param \Mmi\Orm\Query $query
@return GridState
@throws GridException
Stosuje filtry na zapytaniu