@param array $filter

@throws \Doctrine\DBAL\DBALException
@throws \Mindy\QueryBuilder\Exception\NotSupportedException

@return string
186939
public function getSql($filter = []): string
    {
        if ($filter) {
            $this->filter($filter);
        }
        $qb = clone $this->getQueryBuilder();

        return $qb->toSQL();
    }
1147491
public function getFilter($filter) {
        if ($this->hasFilter($filter)) {
            return $this->_filters[$filter];
        }

        throw new MissingFilterException(sprintf('Filter %s does not exist', $filter));
    }
737165
protected function getPredicatesFromFilterCondition($filter)
    {
        $predicates = [];
        $regex = "/(^|\b)(\w+\:\w+)\.(l|u)(\b|$)/";
        foreach($filter as $key=>$condition)
        {
            if(is_string($key))
            {
                $numMatches = preg_match_all($regex, $key, $matches);
                for($i = 0; $i < $numMatches; $i++)
                {
                    if(isset($matches[2][$i]))
                    {
                        $predicates[] = $matches[2][$i];
                    }
                }
            }
            if(is_string($condition))
            {
                $numMatches = preg_match_all($regex, $condition, $matches);
                for($i = 0; $i < $numMatches; $i++)
                {
                    if(isset($matches[2][$i]))
                    {
                        $predicates[] = $matches[2][$i];
                    }
                }
            }
            elseif(is_array($condition))
            {
                array_merge($predicates, $this->getPredicatesFromFilterCondition($condition));
            }
        }
        return $predicates;
    }
49453
public function withFilter(Filter $filter)
    {
        if ($this->value->isNull()) {
            return null;
        }

        return $this->applyFilter($filter);
    }
883981
public function getAll(array $filter)
    {
        $this->select = $this->readSql->select('history');
                    
        $this->joinAuth()->joinAclRole();
        
        $this->filter($filter)->sort($filter); 

        if (array_key_exists('pagination', $filter)) {
            if ($filter['pagination'] == 'off') {  
                return $this->getRows();    
            }
        }

        return $this->getPaginator();
    }
1100325
public function find(array $filter = [], array $options = [])
    {
        $options += ['typeMap' => $this->typeMap];
        $options = QueryOptionsResolver::resolveStatic($options);
        $typeMap = $options['typeMap'];
        unset($options['typeMap']);

        if (isset($options['readPreference'])) {
            $readPreference = $options['readPreference'];
            unset($options['readPreference']);
        } else {
            $readPreference = $this->readPreference;
        }

        $query = new Query($filter, $options);
        $query->setDefaultReadConcern($this->readConcern);

        $cursor = $this->manager->executeQuery(
            $this->getNamespace(),
            $query,
            $readPreference
        );

        $cursor->setTypeMap($typeMap);

        return $cursor;
    }
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;
    }
33073
protected function getFilterParams(array &$filters, $filter)
    {
        $fragments = preg_split('%;%', $filter, -1, PREG_SPLIT_NO_EMPTY);

        $name = array_shift($fragments);
        $params = [];

        foreach ($fragments as $param) {
            list($key, $value)  = explode('=', $param);
            $params[$key] = $value;
        }

        $filters[$name] = $params;
    }
93612
private function buildEntry(Filter $filter): string
    {
        $entry = collect($filter->toArray())
            ->map(function ($value, $key): string {
                return $this->buildProperty($value, $key);
            })
            ->implode($this->glue());

        return collect(['<entry>', $entry, '</entry>'])->implode($this->glue());
    }
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;
    }
197294
protected function sQueryMySqlIndexes($filterArray = null)
    {
        return 'SELECT '
            . '`KCU`.`CONSTRAINT_SCHEMA`, '
            . $this->sQueryMySqlIndexesColumns() . ' '
            . 'FROM `information_schema`.`KEY_COLUMN_USAGE` `KCU` '
            . 'INNER JOIN `information_schema`.`COLUMNS` `C` ON ((' . implode(') AND (', [
                '`C`.`TABLE_SCHEMA` = `KCU`.`TABLE_SCHEMA`',
                '`C`.`TABLE_NAME` = `KCU`.`TABLE_NAME`',
                '`C`.`COLUMN_NAME` = `KCU`.`COLUMN_NAME`',
            ]) . ')) '
            . 'LEFT JOIN `information_schema`.`REFERENTIAL_CONSTRAINTS` `RC` ON ((' . implode(') AND (', [
                '`KCU`.`CONSTRAINT_SCHEMA` = `RC`.`CONSTRAINT_SCHEMA`',
                '`KCU`.`CONSTRAINT_NAME` = `RC`.`CONSTRAINT_NAME`',
            ]) . ')) '
            . $this->sManageDynamicFilters($filterArray, 'KCU')
            . 'ORDER BY `KCU`.`TABLE_SCHEMA`, `KCU`.`TABLE_NAME`'
            . $this->xtraSoring($filterArray, 'COLUMN_NAME') . ';';
    }
1209254
public function filter($filter)
    {
        if (!is_a($filter, FilterBuilder::class)) {
            throw new \Exception ("Filter must be extend class 'FilterBuilder'");
        }

        $this->filter = $filter;

        return $this;
    }
630274
public function dataTypesGet( $filter = null )
    {

        // array of string
        if( func_num_args() > 1 and \Bond\array_check( 'is_string', func_get_args() ) ) {
            $filter = func_get_args();
        }

        // filter constants
        if( is_int( $filter ) ) {

            $dataTypes = array();

            if( $filter & DataType::PRIMARY_KEYS ) {
                $dataTypes += array_filter(
                    $this->dataTypes,
                    function( $dataType ) {
                        return $dataType->isPrimaryKey();
                    }
                );
            }

            if( $filter & DataType::FORM_CHOICE_TEXT ) {
                $dataTypes += array_filter(
                    $this->dataTypes,
                    function( $dataType ) {
                        return $dataType->isFormChoiceText();
                    }
                );
            }

            if( $filter & DataType::AUTOCOMPLETE ) {
                $dataTypes += array_filter(
                    $this->dataTypes,
                    function( $dataType ) {
                        return $dataType->isAutoComplete();
                    }
                );
            }

            // todo. build a datatype from the $this->links et al
            if( $filter & DataType::LINKS ) {
            }

            return $dataTypes;

        }

        if( is_string( $filter ) ) {
            $filter = array( $filter );
        }

        if( is_array($filter) ) {

            $result = array_intersect_key( $this->dataTypes, array_flip( $filter ) );

            if ( count($result) != count($filter) ) {
                throw new \InvalidArgumentException(
                    sprintf(
                        'Unknown columns "%s" passed to %s->dataTypesGet()',
                        implode( '","', array_diff( $filter, array_keys( $result ) ) ),
                        $this->entity
                    )
                );
            }

            return $result;
        }

        if( $filter instanceof \Closure ) {
            return array_filter( $this->dataTypes, $filter );
        }

        return $this->dataTypes;
    }
768225
protected function buildQueryByFilter($query, $filter)
    {
        $tableName = $this->getBlankModel()->getTable();

        $query = $this->queryOptions($query);

        if (count($this->querySearchTargets) > 0 && array_key_exists('query', $filter)) {
            $searchWord = Arr::get($filter, 'query');
            if (!empty($searchWord)) {
                $query = $query->where(function($q) use ($searchWord) {
                    foreach ($this->querySearchTargets as $index => $target) {
                        if ($index === 0) {
                            $q = $q->where($target, 'LIKE', '%'.$searchWord.'%');
                        } else {
                            $q = $q->orWhere($target, 'LIKE', '%'.$searchWord.'%');
                        }
                    }
                });
            }
            unset($filter['query']);
        }

        foreach ($filter as $column => $value) {
            if (is_array($value)) {
                $query = $query->whereIn($tableName.'.'.$column, $value);
            } else {
                $query = $query->where($tableName.'.'.$column, $value);
            }
        }

        return $query;
    }
919629
public function updateBy(Entity $entity, array $filter = [])
    {
        if (!$entity->getValidator()->validate()) {
            throw new Exception\ValidatorException($entity->getValidator());
        }

        try {
            return $this->query()->update($entity->getData())
                ->setFilter($filter)
                ->run($this->connection);
        } catch (Exception\QueryException $e) {
            throw new Exception\RepositoryException($e->getMessage());
        }
    }
550119
public static function filterByUuid($filter)
    {
        $operator = Arr::get($filter, 'operator');
        $method = Arr::get($filter, 'method');
        $arguments = Arr::get($filter, 'arguments');
        $value_one = Arr::get($filter, 'value_one');
        $value_two = Arr::get($filter, 'value_two');
        $settings = Arr::get($filter, 'settings');
        $positive = Arr::get($filter, 'positive');

        switch ($operator) {
            case 'IN':
                $method = 'whereIn';
                $arguments = [static::getListFromString($value_one)];
                break;
            case 'NOT_IN':
                $method = 'whereNotIn';
                $arguments = [static::getListFromString($value_one)];
                break;
            case 'NULL':
                $method = 'whereNull';
                break;
            case 'NOT_NULL':
                $method = 'whereNotNull';
                break;
        }

        return [
            'operator'  => $operator,
            'method'    => $method,
            'arguments' => $arguments,
            'value_one' => $value_one,
            'value_two' => $value_two,
            'settings'  => $settings,
            'positive'  => $positive,
        ];
    }
495551
public static function convertFilter($filter)
    {
        if (!$filter) {
            return array();
        }
        if (is_array($filter)) {
            return $filter;
        }

        $filter_array = array();
        $rules        = explode('|', $filter);
        foreach ($rules as $rule) {
            list($name, $arg) = self::get_name_and_arg($rule);
            $filter_array[$name] = $arg;
        }

        return $filter_array;
    }