src/GenericFilter.php
public function toQuery( Query $query, array $columns = [], $alias = '' ) {

		foreach( $this->criteria as $column => $criteria ) {

			if( !$column = $this->getColumnName($columns, $column, $alias) )
				continue;

			foreach( $criteria as $operator => $value ) {
				$query->where($column, $operator, $value);
			}

		}

		foreach( $this->getOrder() as $column => $ascending ) {
			$column = $this->getColumnName($columns, $column, $alias);
			if( !$column )
				continue;
			$query->orderBy($column, $ascending);
		}

		if( $this->offset )
			$query->offset($this->offset);

		if( $this->limit )
			$query->limit($this->limit);

		return $query;

	}
public function toQuery( Query $query, array $columns = [], $alias = '' ) {

		foreach( $this->criteria as $column => $criteria ) {

			if( !$column = $this->getColumnName($columns, $column, $alias) )
				continue;

			foreach( $criteria as $operator => $value ) {
				$query->where($column, $operator, $value);
			}

		}

		foreach( $this->getOrder() as $column => $ascending ) {
			$column = $this->getColumnName($columns, $column, $alias);
			if( !$column )
				continue;
			$query->orderBy($column, $ascending);
		}

		if( $this->offset )
			$query->offset($this->offset);

		if( $this->limit )
			$query->limit($this->limit);

		return $query;

	}
public function toQuery ( Query $ query , array $ columns = [ ] , $ alias = '' ) { foreach ( $ this -> criteria as $ column => $ criteria ) { if ( ! $ column = $ this -> getColumnName ( $ columns , $ column , $ alias ) ) continue ; foreach ( $ criteria as $ operator => $ value ) { $ query -> where ( $ column , $ operator , $ value ) ; } } foreach ( $ this -> getOrder ( ) as $ column => $ ascending ) { $ column = $ this -> getColumnName ( $ columns , $ column , $ alias ) ; if ( ! $ column ) continue ; $ query -> orderBy ( $ column , $ ascending ) ; } if ( $ this -> offset ) $ query -> offset ( $ this -> offset ) ; if ( $ this -> limit ) $ query -> limit ( $ this -> limit ) ; return $ query ; }
Apply the filter to a database Query
@param  Query  $query
@param  array  $columns a map of field names to database column names
@return Query
Apply the filter to a database Query