@param string|array $filter Filter for querying records by
@param array        $params replacement parameters

@return array
19271
protected static function parseFilter($filter, $params = [])
    {
        if (empty($filter)) {
            return '';
        }

        if (is_array($filter)) {
            return ''; // todo need to build from array of parts
        }

        // handle logical operators first
        // supported logical operators are or, and, not
        $search = [' || ', ' && ', ' OR ', ' AND ', ' NOR ', ' NOT '];
        $replace = [' or ', ' and ', ' or ', ' and ', ' nor ', ' not '];
        $filter = trim(str_ireplace($search, $replace, ' ' . $filter)); // space added for 'not' case

        // the rest should be comparison operators
        // supported comparison operators are eq, ne, gt, ge, lt, le
        $search =
            ['!=', '>=', '<=', '>', '<', '=', ' EQ ', ' NE ', ' LT ', ' LTE ', ' LE ', ' GT ', ' GTE', ' GE '];
        $replace = [
            ' ne ',
            ' ge ',
            ' le ',
            ' gt ',
            ' lt ',
            ' eq ',
            ' eq ',
            ' ne ',
            ' lt ',
            ' le ',
            ' le ',
            ' gt ',
            ' ge ',
            ' ge '
        ];
        $filter = trim(str_ireplace($search, $replace, $filter));

//			WHERE name LIKE "%Joe%"	not supported
//			WHERE name LIKE "%Joe"	not supported
//			WHERE name LIKE "Joe%"	name ge 'Joe' and name lt 'Jof';
//			if ( ( '%' == $val[ strlen( $val ) - 1 ] ) &&
//				 ( '%' != $val[0] ) )
//			{
//			}

        if (!empty($params)) {
            foreach ($params as $name => $value) {
                $filter = str_replace($name, $value, $filter);
            }
        }

        return $filter;
    }
15335
protected static function buildCriteriaArray($filter, $params = null, $ss_filters = null)
    {
        // interpret any parameter values as lookups
        $params = static::interpretRecordValues($params);
        // or as Mongo objects
        $params = static::toMongoObjects($params);

        // build filter array if necessary
        if (!is_array($filter)) {
            Session::replaceLookups($filter);
            $test = json_decode($filter, true);
            if (!is_null($test)) {
                // original filter was a json string, use it as array
                $filter = $test;
            }
        }
        $criteria = static::buildFilterArray($filter, $params);

        // add server-side filters if necessary
        $serverCriteria = static::buildSSFilterArray($ss_filters);
        if (!empty($serverCriteria)) {
            $criteria = (!empty($criteria)) ? ['$and' => [$criteria, $serverCriteria]] : $serverCriteria;
        }

        return $criteria;
    }
1052485
public function filter(array $filters)
	{
		foreach ($filters as $filter) {
			if ($filter->isValueSet()) {
				if ($filter->hasConditionCallback()) {
					Callback::invokeArgs(
						$filter->getConditionCallback(),
						[$this->data_source, $filter->getValue()]
					);
				} else {
					if ($filter instanceof Filter\FilterText) {
						$this->applyFilterText($filter);
					} elseif ($filter instanceof Filter\FilterMultiSelect) {
						$this->applyFilterMultiSelect($filter);
					} elseif ($filter instanceof Filter\FilterSelect) {
						$this->applyFilterSelect($filter);
					} elseif ($filter instanceof Filter\FilterDate) {
						$this->applyFilterDate($filter);
					} elseif ($filter instanceof Filter\FilterDateRange) {
						$this->applyFilterDateRange($filter);
					} elseif ($filter instanceof Filter\FilterRange) {
						$this->applyFilterRange($filter);
					}
				}
			}
		}

		return $this;
	}
438089
public function list($filter = [], $num = 30, $offset = 0, $cols = null) {
		$query = $this->newSelect();
		if (is_array($cols)) {
			$query->addColumns(...$cols);
		}
		foreach ($filter as $k => $v) {
			$query->andWhere(field($k)->eq($v));
		}
		$query->offset($offset)->limit($num);
		return $this->execute($query);
	}
979438
public function getIterator(IteratorFilter $filter = null)
    {
        if (is_null($filter)) {
            $filter = new IteratorFilter();
        }

        $param = [];
        $formatter = new IteratorFilterSqlFormatter();
        $sql = $formatter->getFilter($filter->getRawFilters(), $param);

        $query = Query::getInstance()
            ->table($this->getUserDefinition()->table())
            ->where($sql, $param);

        return $this->userRepository->getByQuery($query);
    }
529411
private function extractFilters(array $params)
    {
        if (false === $this->issetNotEmpty(self::PARAM_FILTERING, $params)) {
            return $this;
        }
        $filters = $params[self::PARAM_FILTERING];
        if (!is_array($filters)) {
            throw RestException::invalidQueryParam(self::PARAM_FILTERING, 'The filter parameter must be an array keyed by filter name and value.');
        }
        foreach ($filters as $key => $value) {
            $this->filters[$key] = $value;
        }
        return $this;
    }
954947
public function get_filter_values($filter) {
        if ($allvalues = (array) $this->get_config('filtervalues')) {
            if (isset($allvalues[$filter])) {
                return $allvalues[$filter];
            }
        }

        return [];
    }
70849
public static function getOptionSets($filter = array())
    {
        $filter = Filter::create($filter);
        return self::getCollection('/optionsets' . $filter->toQuery(), 'OptionSet');
    }
844629
public function find(array $filter = [], array $options = [])
    {
        $cursor = $this->collection->find($filter, $options);
        $cursor->setTypeMap(['root' => 'array', 'document' => 'array', 'array' => 'array']);

        foreach ($cursor as $originalValues) {
            $values = $this->convertValues->convertToPHPValues($originalValues);

            $object = $this->hydrator->hydrate($values);

            $this->changesCollector->register($object, $originalValues);

            yield $object;
        }
    }
1001749
public function count(string $table, string $filter = '', array $params = []): int
    {
        $query = [
            'table' => $table,
            'fields' => 'COUNT(*)'
        ];
        
        if ($filter) {
            
            $query['filter'] = $filter;
            
            if ($params) {
                $query['params'] = $params;
            }
        }
        
        $this->qb($query);
        
        return $this->value();
    }
354537
public function get_single_record(array $filter) {
		if(is_array($filter) && count($filter)) {
			try {
				$data = $this->get_records($filter, null, 1);
				
				if(is_array($data)) {
					$keys = array_keys($data);
					$retval = $data[$keys[0]];
				}
				else {
					//technically, the call to get_records() got boolean(false) from cs_phpDB::run_query(), so we could just return $data directly...
					$retval = false;
				}
			}
			catch(Exception $e) {
				throw new Exception(__METHOD__ .":: failed to retrieve record, DETAILS::: ". $e->getMessage());
			}
		}
		else {
			throw new Exception(__METHOD__ .":: no filter passed");
		}
		
		return($retval);
	}
690759
public static function filter(array $metadatas, $filter) : array
    {
        $metadatas = new MetadataFilter(new ArrayIterator($metadatas), $filter);
        return iterator_to_array($metadatas);
    }
626488
public function getOptions($filters = null)
    {
        if (!$filters) {
            return $this->_parameters;
        }

        $result = [];

        foreach ($this->_parameters as $param) {
            $result[] = $this->filter($param, $filters);
        }

        return $result;
    }
11249
public function getDataForExport($filter, $columns = array())
	{
        $select = $this->tableGateway->getSql()->select();
        $select->columns(array('*'));
        
        $w = new Where();
        $filters = array();
        $likes = array();
        
        foreach($columns as $columnKeys) 
        {
            $likes[] = new Like($columnKeys, '%'.$filter.'%');
        }
        
        $filters = array(new PredicateSet($likes, PredicateSet::COMBINED_BY_OR));
        
        $select->where($filters);
        
        $resultSet = $this->tableGateway->selectWith($select);
        
        return $resultSet;
        
	}
373679
public function getParamsWith($filter)
    {
        // Convert $filter to array if necessary
        if (!is_array($filter)) {
            $filter = preg_split("/, */", $filter, -1, PREG_SPLIT_NO_EMPTY);
        }

        $params = $this->getParams();
        $filter = array_flip($filter);

        return array_intersect_key($params, $filter);
    }
622256
protected function filtertextToArray(string $filter = null)
    {
        $resultArray = [];

        if (!empty($filter)) {
            $filterArray = explode(self::SEPARATOR_ENTRY, $filter);

            foreach ($filterArray as $key => $value) {
                $entryArray = explode(self::SEPARATOR_KEY_VALUE, $value);
                $resultArray[$entryArray[0]] = $entryArray[1];
            }
        }

        return $resultArray;
    }
1323999
public function objectsList($filter = null, $params = null)
    {
        //====================================================================//
        // Stack Trace
        Splash::log()->trace();

        //====================================================================//
        // Prepare Query Builder
        /** @var QueryBuilder $queryBuilder */
        $queryBuilder = $this->repository->createQueryBuilder('c');
        // Setup Results Offset
        if (isset($params['offset']) && is_int($params['offset'])) {
            $queryBuilder->setFirstResult($params['offset']);
        }
        // Limit Results Number
        if (isset($params['max']) && is_int($params['max'])) {
            $queryBuilder->setMaxResults($params['max']);
        }

        //====================================================================//
        // Add List Filters
        if (!empty($filter)) {
        }

        //====================================================================//
        // Load Objects List
        $rawData = $queryBuilder->getQuery()->getResult();

        //====================================================================//
        // Parse Data on Result Array
        $response = array();
        foreach ($rawData as $object) {
            $response[] = $this->getObjectListArray($object);
        }

        //====================================================================//
        // Parse Meta Infos on Result Array
        $response['meta'] = array(
            'total' => count($rawData),
            'current' => $this->getTotalCount(),
        );

        //====================================================================//
        // Return result
        return $response;
    }