Query

@param array $filterArray
@return string
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') . ';';
    }
1074350
public function getFilter($filtername) {
        $filter = null;
        if (!is_null($this->filters) && isset($this->filters[$filtername])) {
            $filter = $this->filters[$filtername];
        }
        return $filter;
    }
1051985
public function getSearchRequest($filter, $limit = 1, $conditions = [])
    {
        $self = $this;
        $knownFilters = $this->_getSearchFilters();
        $request = new StorageDataRequest(
            [$filter, $limit, $conditions],
            function ($filter, $limit, $conditions) use ($self, $knownFilters) {
                $items = $self->getAllItems();
                $results = [];
                $filterRules = [];
                
                foreach ($filter as $filterRequest) {
                    if (\count($filterRequest) === 3) {
                        list ($key, $compare, $compareValue) = $filterRequest;
                        
                        if (isset($knownFilters[$compare])) {
                            $filterRules[] = [$key, $knownFilters[$compare], $compareValue];
                        } else {
                            trigger_error('Comparator not found for filter: '.json_encode($filterRequest).'');
                        }
                    } else {
                        trigger_error('Strange filter: less than 3 parameters, '.json_encode($filterRequest));
                    }
                }
                
                foreach ($items as $id) {
                    $pointer = $self->getPointer($id);
                    $isOk = true;
                    if ($pointer) {
                        $record = json_decode(stream_get_contents($pointer), true);
                        
                        if (isset($record[self::F_DATA])) {
                            foreach ($filterRules as $filterRule) {
                                list ($key, $function, $filterRequest) = $filterRule;
        
                                $isOk = $isOk && call_user_func($function, $record[self::F_DATA][$key] ?? null, $filterRequest);
        
                                if (!$isOk) {
                                    break;
                                }
                            }
    
                            if ($isOk) {
                                $results[$id] = [$this->primaryKey => $id] + $record[self::F_DATA];
                            }    
                        }
                        
                        $self->closePointer($pointer);
                        
                        if (count($results) >= $limit) {
                            break;
                        }
                    }
                }
                
                if ($results && $conditions) {
                    $self->applyConditions($results, $conditions);
                }
            
                return $results;
            }
        );
    
        return $request;
    }
1006194
public function findAllWithPagination($filters, $limit, $offset, $resultInArray = FALSE)
    {
        $where = $this->getQueryFilter($filters);
        $query = $this->getEntityManager()->createQuery('SELECT m FROM FulgurioLightCMSBundle:Media m ' . $where . ' ORDER BY m.created_at DESC')->setMaxResults($limit)->setFirstResult($offset);
        if (!empty($filters))
        {
            foreach ($filters as $filterKey => $filterValue)
            {
                $query->setParameter($filterKey, $filterValue);
            }
        }
        if ($resultInArray)
        {
            return $query->getArrayResult();
        }
        return $query->getResult();
    }
221008
public function driverQuery($query, $filteredIndex=TRUE): ?array
	{
		// Call the appropriate method, if it exists
		if (\is_string($query) && method_exists($this->sql, $query))
		{
			$query = $this->getSql()->$query();
		}

		// Return if the values are returned instead of a query,
		// or if the query doesn't apply to the driver
		if ( ! \is_string($query))
		{
			return $query;
		}

		// Run the query!
		$res = $this->query($query);

		$flag = $filteredIndex ? PDO::FETCH_NUM : PDO::FETCH_ASSOC;
		$all = $res->fetchAll($flag);

		return $filteredIndex ? \dbFilter($all, 0) : $all;
	}
220797
public function addMultiple($filterArray)
    {
        foreach($filterArray as $key => $value) {
            if (!$this->hasWithName($key)) {
                $this->add($value, $key);
            }
        }

        return $this;
    }
1057618
public function getAll(array $filters = [])
    {
        $vars = $this->getEnvironmentVariables();

        foreach ($filters as $filter) {
            if (!$filter instanceof FilterInterface) {
                throw new FilterException(sprintf(
                    '%s %s %s',
                    'The $filters param must be an array',
                    'and your values must be an instance of',
                    '\Cekurte\Environment\Contract\FilterInterface'
                ));
            }

            $vars = $filter->filter($vars);
        }

        $callback = function ($rawValue) {
            return $this->getValue($rawValue);
        };

        return array_map($callback, $vars);
    }
1374975
public function getQuery($key, $def = "", $filter = null)
    {
        $val = $this->query[$key];
        if ($filter) {
            $val = Filter::factory($val, $filter);
        }
        return $val === null ? $def : $val;
    }
1034739
public function getFiltersArrayItem($filterIdentifier)
    {
        return isset($this->filtersArray[$filterIdentifier]) ? $this->filtersArray[$filterIdentifier] : false;
    }
1256419
public function list(array $filters = [])
    {
        $data = [
            'filters' => json_encode($filters),
        ];

        $url = $this->url.'?'.http_build_query($data);

        return $this->curl->get($url);
    }
1299331
private function createQueryFilter()
    {
        if (count($this->queryFilter()) > 0) {
            foreach ($this->queryFilter() as $filter => $parameters) {
                if (!is_array($parameters)) {
                    $parameters = [$parameters];
                }
                $this->query = call_user_func_array([$this->query, $filter], $parameters);
            }
        }
    }
147823
public function query(array $stream, array $filters = [])
    {
        $qb = QueryBuilder::create((array)$stream);

        foreach ($filters as $key => $value) {
            $qb->addCriterion($key, $value);
        }

        $qb->sortedBy('occurred_on', 'ASC');

        return $qb->getResults();
    }
881225
public function actionFilter($filterName, $query = null)
    {
        $this->checkAccess('filter');
        
        $model = $this->model;
        
        $filterName = Html::encode($filterName);
        
        if (!array_key_exists($filterName, $model->ngRestFilters())) {
            throw new InvalidCallException("The requested filter '$filterName' does not exists in the filter list.");
        }

        $find = $model->ngRestFilters()[$filterName];

        if ($query) {
            foreach ($model->getNgRestPrimaryKey() as $pkName) {
                $searchQuery = $model->ngRestFullQuerySearch($query)->select([$model->tableName() . '.' . $pkName]);
                $find->andWhere(['in', $model->tableName() . '.' . $pkName, $searchQuery]);
            }
        }

        $this->appendPoolWhereCondition($find);
        
        return new ActiveDataProvider([
            'query' => $find,
            'pagination' => $this->pagination,
            'sort' => [
                'attributes' => $this->generateSortAttributes($model->getNgRestConfig()),
            ]
        ]);
    }
106630
public function getFilterData($filterId = null)
    {
        if ($filterId !== null) {
            foreach ($this->filterData as $filter) {
                if ($filter->getId() == $filterId) {
                    return $filter;
                }
            }
            return null;
        } else {
            return $this->filterData;
        }
    }
1229898
protected function applyFilter(array $responseArray, array $filter)
    {
        $arrayIntersect = null;
        //Check if its a sequential array. Presence of sequential arrays mean that the filed is a collection
        //and the filtering will be applied to all the collection items
        if (!(bool)count(array_filter(array_keys($responseArray), 'is_string'))) {
            foreach ($responseArray as $key => &$item) {
                $arrayIntersect[$key] = $this->recursiveArrayCompare($item, $filter);
            }
        } else {
            $arrayIntersect = $this->recursiveArrayCompare($responseArray, $filter);
        }
        return $arrayIntersect;
    }
643710
private function getSearchQuery()
    {
        $queries = [];

        foreach ($this->queryProviders as $queryProvider) {
            $queries[] = $queryProvider->getQuery();
        }

        return array_filter($queries);
    }
165271
protected function searchFilter( array $data ) {

		$keyword = ( ! empty( $_REQUEST['s'] ) ) ? (string) trim( $_REQUEST['s'] ) : false;

		if ( ! $keyword ) {
			return $data;
		}

		$filtered_data = [];
		foreach ( $data as $_ => $val ) {
			if ( $this->atLeastOneKeyword( $keyword, $val ) ) {
				$filtered_data[] = $val;
			}
		}

		return $filtered_data;
	}