Sets the query filters when getting the rows.

@param mixed                              $filters
@param \Illuminate\Database\Query\Builder $query
@param \Illuminate\Database\Query\Builder $countQuery
@param array                              $selects
972324
public function setFilters($filters, QueryBuilder &$query, QueryBuilder &$countQuery, &$selects)
    {
        //then we set the filters
        if ($filters && is_array($filters)) {
            foreach ($filters as $filter) {
                //get the field object
                $fieldObject = $this->fieldFactory->findFilter($filter['field_name']);

                //set the filter on the object
                $fieldObject->setFilter($filter);

                //filter the query objects, only pass in the selects the first time so they aren't added twice
                $fieldObject->filterQuery($query, $selects);
                $fieldObject->filterQuery($countQuery);
            }
        }
    }
1049743
protected function getQueryBuilder(array $filters = [], array $sorting = [])
    {
        $queryBuilder = $this->getBaseQueryBuilder();
        if (!empty($filters)) {
            $this->addFilters($queryBuilder, $filters);
        }

        if (empty($sorting)) {
            $this->addSorting($queryBuilder, $this->getDefaultSorting());
        } else {
            $this->addSorting($queryBuilder, $sorting);
        }

        return $queryBuilder;
    }
1138914
public function selectOne($query, $bindings = [])
    {
        $start = $this->getLogTime();

        try {

            $result = $this->wpdb->get_row($this->bindParams($query, $bindings));

            if ($result === false || $this->wpdb->last_error) {
                throw new QueryException($query, $bindings, new \Exception($this->wpdb->last_error));
            }

            return $result;

        } catch (QueryException $e) {
            throw $e;
        } finally {
            $this->logQuery($query, $bindings, $this->getElapsedTime($start));
        }
    }
386239
public function filter(array $filters)
	{
		foreach ($filters as $filter) {
			if ($filter->isValueSet()) {
				if ($filter->hasConditionCallback()) {
					$data = (array) call_user_func_array(
						$filter->getConditionCallback(),
						[$this->data, $filter->getValue()]
					);
					$this->setData($data);
				} else {
					$data = array_filter($this->data, function ($row) use ($filter) {
						return $this->applyFilter($row, $filter);
					});
					$this->setData($data);
				}
			}
		}

		return $this;
	}
981220
public function scopeFiltered(Builder $builder, array $query = [])
    {
        $query = (array)($query ?: Input::all());
        $this->validateFieldNames($query);

        $mode = $this->getQueryMode($query);
        $query = $this->filterNonSearchableParameters($query);
        $constraints = $this->getConstraints($builder, $query);

        $this->applyConstraints($builder, $constraints, $mode);
    }
500263
public function withFilters(array $filters = null)
    {
        if ($filters) {
            foreach ($filters as $filter) {
                switch ($filter['type']) {
                    case 'select':
                        $this->select($filter['fields']);
                        break;
                    case 'andWhere':
                        $this->andWhere($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'orWhere':
                        $this->orWhere($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'andHaving':
                        $this->andHaving($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'orHaving':
                        $this->orHaving($filter['field'], $filter['operation'], $filter['value']);
                        break;
                    case 'addGroupBy':
                        $this->addGroupBy($filter['field']);
                        break;
                    case 'addOrderBy':
                        $this->addOrderBy($filter['field'], $filter['order']);
                        break;
                    case 'fkAddOrderBy':
                        $this->fkAddOrderBy($filter['field'], $filter['fkField'], $filter['order']);
                        break;
                    case 'paginate':
                        if (isset($filter['page'])) {
                            $this->paginate($filter['limit'], $filter['page']);
                        } else {
                            $this->paginate($filter['limit']);
                        }
                        break;
                }
            }
        }

        return $this;
    }
851078
private function createFilteredQuery(array $filters)
    {
        $qb = $this->createQuery('entity');

        foreach ($filters as $field => $filter) {
            $qb->andWhere(is_array($filter)
                    ? sprintf('entity.%s in (:%s)', $field, $field)
                    : sprintf('entity.%s = :%s', $field, $field)
                )
                ->setParameter(sprintf(':%s', $field), $filter)
            ;
        }

        return $qb->getQuery();
    }
841369
private function addBoolQuery($filterName, array $filters, $field, $operator, BoolQuery $query, &$queriesCount)
    {
        if (0 !== count($tags = $this->getFilter($filters, $filterName, []))) {
            ++$queriesCount;
            $query->add($this->getBoolQuery($field, $tags, $operator));
        }
    }
788510
public function applyFilterSelect(Filter\FilterSelect $filter)
	{
		foreach ($filter->getCondition() as $column => $value) {
			$expr = Criteria::expr()->eq($column, $value);
			$this->criteria->andWhere($expr);
		}
	}
655526
public function count($searchSpec, array $filters = [])
    {
        $filters['_id.type'] = $searchSpec;
        return $this->getCollectionForSearchSpec($searchSpec)->count($filters);
    }
388624
public function applyFilters(Builder $query, string $alias = null)
    {
        foreach ($this->getFilters() as $filter) {
            $filter->apply($query, $alias);
        }
    }
406065
private function configureWindow(SelectQuery $query, array $orderBy, int $limit = 0)
    {
        if (!empty($orderBy)) {
            $decorator = new AliasDecorator($query, 'where', $this->getAlias());
            $decorator->orderBy($orderBy);
        }

        if ($limit !== 0) {
            $query->limit($limit);
        }
    }
894883
public function paginate(Query $query, array $countFields = [], $total = false)
    {
        $limit = $this->defaultLimit;
        if (in_array((integer)$this->request->getQuery('l', 0), $this->limits)) {
            $limit = (integer)$this->request->getQuery('l');
            $this->activeLimit = $limit;
        }
        if (!$this->activeLimit) {
            $lastLimit = $this->request->getSession()->read(join('.', [
                'LIMIT_' . $this->request->getParam('plugin'),
                $this->controller->getName(),
                $this->action
            ]));
            if ($lastLimit) {
                $limit = $lastLimit;
            }
            $this->activeLimit = $limit;
        }
        $this->request = $this->request->withData('l', $limit);

        if ($total === false) {
            $countQuery = clone $query;
            if (!empty($countFields)) {
                $countQuery->select($countFields);
            }
            $total = $countQuery->count();
        }

        if ($limit !== null && $total !== null) {
            $pages = ceil($total / $limit);
            if ($this->page > $pages) {
                $this->page = $pages;
            }
            if ($this->page < 1) {
                $this->page = 1;
            }
            $offset = ($this->page > 1) ? ($this->page - 1) * $limit : 0;
            $from = ($offset > 0) ? $offset + 1 : 1;
            $to = (($from + $limit - 1) > $total) ? $total : $from + $limit - 1;

            $query->limit($limit)->offset($offset);

            $this->paginationParams = [
                'from' => ($total === 0) ? 0 : $from,
                'page' => $this->page,
                'pages' => ($total === 0) ? 1 : $pages,
                'to' => $to,
                'total' => $total,
                'defaultLimit' => $this->defaultLimit,
                'limits' => array_combine($this->limits, $this->limits),
                'passParams' => []
            ];

            if (!empty($this->_passParams)) {
                $this->paginationParams['passParams'] = $this->_passParams;
            }
        }

        return $query;
    }
892313
protected function configureQuery(SelectQuery $query, bool $loadColumns = true): SelectQuery
    {
        //Clarifying table name
        $query->from("{$this->getTable()} AS {$this->getAlias()}");

        //Columns to be loaded for primary model
        if ($loadColumns) {
            $this->mountColumns($query, true, '', true);
        }

        return parent::configureQuery($query, $loadColumns);
    }
1314906
public function filterQuery(QueryBuilder &$query, &$selects = null)
    {
        //if the field isn't empty
        if ($this->getOption('value') !== '') {
            $query->where($this->config->getDataModel()->getTable().'.'.$this->getOption('field_name'), '=', $this->getOption('value'));
        }
    }
1228275
public function filterQuery(QueryBuilder &$query, &$selects = null)
    {
        //run the parent method
        parent::filterQuery($query, $selects);

        //if there is no value, return
        if (!$this->getOption('value')) {
            return;
        }

        $query->where($this->getOption('foreign_key'), '=', $this->getOption('value'));
    }
851785
public function setFilters($filters = []) {
		if ($filters) {
			foreach ($filters as $key => $value) {
				$this->setFilter($key, $value);
			}
		}

		return $this;
	}