Returns the condition to be used with SQL where
@param array $data filter settings
@return array sql string and $params
428934
public function get_sql_filter($data) {
        static $counter = 0;
        $name = 'ex_select'.$counter++;

        $operator = $data['operator'];
        $value    = $data['value'];
        $field    = $this->_field;

        $params = array();

        switch($operator) {
            case 1: // Equal to.
                $res = "=:$name";
                $params[$name] = $value;
                break;
            case 2: // Not equal to.
                $res = "<>:$name";
                $params[$name] = $value;
                 break;
            default:
                return array('', array());
        }
        return array($field.$res, $params);
    }
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;
	}
1328323
public function filterData(array $data)
    {
        // Filter the sparse field-set if we have a specific list of properties
        // defined that we want.
        $filterProps = $this->filterProps();
        if (!empty($filterProps)) {
            $filteredData = array_filter($data, function ($key) use ($filterProps) {
                return \in_array($key, $filterProps, true);
            }, ARRAY_FILTER_USE_KEY);

            // We must always have some data after filtering, so if our filtered
            // data is empty, we should just ignore it ...
            if (!empty($filteredData)) {
                $data = $filteredData;
            }
        }

        return $data;
    }
1011238
public function get_sql_filter($extra='', array $params=null) {
        global $SESSION;

        $sqls = array();
        if ($extra != '') {
            $sqls[] = $extra;
        }
        $params = (array)$params;

        if (!empty($SESSION->user_filtering)) {
            foreach ($SESSION->user_filtering as $fname => $datas) {
                if (!array_key_exists($fname, $this->_fields)) {
                    continue; // Filter not used.
                }
                $field = $this->_fields[$fname];
                foreach ($datas as $i => $data) {
                    list($s, $p) = $field->get_sql_filter($data);
                    $sqls[] = $s;
                    $params = $params + $p;
                }
            }
        }

        if (empty($sqls)) {
            return array('', array());
        } else {
            $sqls = implode(' AND ', $sqls);
            return array($sqls, $params);
        }
    }
1202319
public function findAllBy(array $conditions = array())
    {
        $sql = sprintf('SELECT * FROM %s', $this->getTableName());
        $whereConditions = $this->assembleEquality($conditions);
        $where = sprintf('WHERE %s', implode(' AND ', $whereConditions));
        $sql .= " $where";

        return $this->selectQuery($sql, $conditions);
    }
840613
public function getRelationQuery(array $data) {
        foreach ($this->links as $key => $val) {
            $this->query->whereIn(
                $val, $this->getKeys($data, $key)
            );
        }
        return $this->query;
    }
1100606
public function search($params)
    {
        $query = Language::find();

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
            'iso_639_1' => $this->iso_639_1,
            'iso_639_2' => $this->iso_639_2,
            'iso_639_3' => $this->iso_639_3,
        ]);
        $query->andFilterWhere(['like', 'name', $this->name]);

        return $dataProvider;
    }
904168
function filter($data = array())
    {
        if (! is_array($data)) {
            return $data;
        }
        // first apply the filters to the ROOT
        if (isset($this->filters[self::SELECTOR_ROOT])) {
            /* @var $rootFilters FilterSet */
            $rootFilters = $this->filters[self::SELECTOR_ROOT];
            $data = $rootFilters->applyFilters($data);
        }
        foreach ($data as $key => $value) {
            $data[$key] = $this->filterItem($data, $key);
        }
        return $data;
    }
1126196
protected function filterOrCondition(array $data, $operator, $operands)
    {
        $parts = [];
        foreach ($operands as $operand) {
            if (is_array($operand)) {
                $parts[] = $this->filterCondition($data, $operand);
            }
        }

        if (empty($parts)) {
            return $data;
        }

        $data = [];
        foreach ($parts as $part) {
            foreach ($part as $row) {
                $pk = $row[$this->_query->primaryKeyName];
                $data[$pk] = $row;
            }
        }

        return $data;
    }
841049
public function search($params)
    {
        $query = Language::find();

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
            'domain_id' => $this->domain_id,
            'bydefault' => $this->bydefault,
            'status' => $this->status,
            'position' => $this->position,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
        ]);

        $query->andFilterWhere(['like', 'slug', $this->slug])
            ->andFilterWhere(['like', 'name', $this->name])
            ->andFilterWhere(['like', 'locale', $this->locale])
            ->andFilterWhere(['like', 'alias', $this->alias])
            ->andFilterWhere(['like', 'icon_id', $this->icon_id]);

        return $dataProvider;
    }
458662
public function filterProtectedData($data)
    {
        if ($data && isset($this['fields']) && isset($this['protected_fields']) && $this['protected_fields']) {
            if (isset($data[0]) || is_numeric(key($data))) {
                foreach ($data as $k => $v) {
                    $data[$k] = static::filterProtectedData($v);
                }
            } else {
                $fields = array_keys($this['fields']);
                $pfields = StringHelper::toArray($this['protected_fields']);
                foreach ($data as $k => $v) {
                    if (in_array($k, $fields) && in_array($k, $pfields)) {
                        unset($data[$k]);
                    }
                }
            }
        }
        
        return $data;
    }
933861
public function update($table, array $data = [], $where = null): array
    {
        if (\is_array($table)) {
            $data = $table[SQL::SET] ?? $table[SQL::VALUES];
            $where = $table;
            $table = $this->getTable($table, SQL::UPDATE);
        } elseif ($where) {
            $where = [SQL::WHERE => $where];
        }

        $fields = [];
        $map = [];

        foreach ($data as $key => $value) {
            $column = $this->columnQuote(\preg_replace("/(\s*\[(\+|\-|\*|\/)\]$)/i", '', $key));

            if ($raw = $this->buildRaw($value, $map)) {
                $fields[] = $column . ' = ' . $raw;
                continue;
            }

            $mapKey = $this->mapKey();
            \preg_match('/(?<column>\w+)(\[(?<operator>\+|\-|\*|\/)\])?/i', $key, $match);

            if (isset($match['operator'])) {
                if (\is_numeric($value)) {
                    $fields[] = $column . ' = ' . $column . ' ' . $match['operator'] . ' ' . $value;
                }
            } else {
                $fields[] = $column . ' = ' . $mapKey;
                $map[$mapKey] = $this->typeMap($value, \gettype($value));
            }
        }

        $sql = 'UPDATE ' . $this->tableQuote($table) . ' SET ' . \implode(', ', $fields) .
            $this->suffixClause($where, $map);

        return [$sql, $map];
    }
1237657
protected function buildQuery($data = null)
    {
        $params = array();

        if ($data instanceof Criteria) {
            $params = array_merge($params, $data->getParams());
            $params['orderBy'] = $data->getOrderBy();
        }

        if ($token = $this->getOption('token', false)) {
            $params['auth'] = $token;
        }

        return $params;
    }
1373099
public function search($params)
    {
        $query = Type::find();

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
            'parent' => $this->parent,
        ]);

        $query->andFilterWhere(['like', 'name', $this->name])
            ->andFilterWhere(['like', 'module', $this->module]);

        return $dataProvider;
    }
262558
protected static function filterValues(array $data)
    {
        $returnValue = array();
        foreach ($data as $d) {
            if ($d !== null) {
                $returnValue[] = $d->getValue();
            } else {
                $returnValue[] = $d;
            }
        }

        return $returnValue;
    }
222796
protected function getConditions()
    {
        $limit  = $this->getLimit();
        $offset = $this->getOffset();
        $order  = $this->getOrder();

        $sql = '';

        if (!empty($order) && is_array($order)) {
            foreach ($order as $field => $type) {
                $order[$field] = $field . ' ' . $type;
            }
            
            $sql .= ' ORDER BY '. implode(', ', $order);
        }

        if (!empty($limit) && $limit > 0) {

            $aux = ' LIMIT ';

            if (isset($offset)) {
                $aux .= $offset . ', ';
            }

            $aux .= $limit;

            $sql .= $aux;
        }

        return $sql;
    }
516304
public function search($params, $dataProviderConfig = [])
    {
        /**
         * @var ActiveRecord
         * @var ActiveRecord $class
         * @var ActiveQuery $query
         */
        $class = get_parent_class();
        $query = $class::find(); // $class::find()->orderBy($sort->orders)->all(); if $sort is Sort

        $dataProvider = new ActiveDataProvider(ArrayHelper::merge(['query' => $query], $dataProviderConfig));

        if (!($this->load($params) && $this->validate())) {
            return $dataProvider;
        }

        foreach ($this->attributes() as $attribute) {
            if (($value = $this->{$attribute}) === null) {
                continue;
            }
            /*
             * Extracts underscore suffix from the key.
             *
             * Examples:
             * client_id -> 0 - client_id, 1 - client, 2 - _id, 3 - id
             * server_owner_like -> 0 - server_owner_like, 1 - server_owner, 2 - _like, 3 - like
             */
            preg_match('/^(.*?)(_((?:.(?!_))+))?$/', $attribute, $matches);

            /// If the suffix is in the list of acceptable suffix filer conditions
            if ($matches[3] && in_array($matches[3], static::$filterConditions, true)) {
                $cmp = $matches[3];
                $attribute = $matches[1];
            } else {
                $cmp = 'eq';
            }
            $query->andFilterWhere([$cmp, $attribute, $value]);
        }

        return $dataProvider;
    }