Set SQL query params for a filter

@param string $field
@param string $type
@param string $filter
@param string $value
@return boolean          True on success
332102
protected function buildFilter($field, $type, $filter, $value)
    {
        if ((is_array($value) && count($value) != 2)
                || (!is_array($value) && ($value !== false && strlen($value) == 0))) {
            return false;
        }
        if (strlen($field) == 0)
            throw new \Exception("Empty 'field'");
        if (strlen($type) == 0)
            throw new \Exception("Empty 'type'");

        if ($type == Table::TYPE_DATETIME) {
            if ($filter == Table::FILTER_BETWEEN
                    && is_array($value) && count($value) == 2) {
                $value = [
                    $value[0] ? new MongoDate($value[0]) : null,
                    $value[1] ? new MongoDate($value[1]) : null,
                ];
            } else if ($filter != Table::FILTER_BETWEEN
                    && is_scalar($value)) {
                $value = new MongoDate($value);
            } else {
                return false;
            }
        } else {
            if ($filter == Table::FILTER_BETWEEN) {
                if (!is_array($value) || count($value) != 2)
                    return false;
            } else if (!is_scalar($value)) {
                return false;
            }
        }

        switch ($filter) {
            case Table::FILTER_LIKE:
                if (!(isset($this->andOps[$field])))
                    $this->andOps[$field] = [];
                $this->andOps[$field][] = [
                    'operator'  => 'equals',
                    'value'     => new MongoRegex('/.*' . preg_quote($value) . '.*/i'),
                ];
                break;
            case Table::FILTER_EQUAL:
                if (!(isset($this->andOps[$field])))
                    $this->andOps[$field] = [];
                $this->andOps[$field][] = [
                    'operator'  => 'equals',
                    'value'     => $value,
                ];
                break;
            case Table::FILTER_BETWEEN:
                if (!(isset($this->andOps[$field])))
                    $this->andOps[$field] = [];
                $this->andOps[$field][] = [
                    'operator'  => 'range',
                    'value1'    => $value[0],
                    'value2'    => $value[1],
                ];
                break;
            case Table::FILTER_NULL:
                if (!(isset($this->andOps[$field])))
                    $this->andOps[$field] = [];
                $this->andOps[$field][] = [
                    'operator'  => 'exists',
                    'value'     => false,
                ];
                break;
            default:
                throw new \Exception("Unknown filter: $filter");
        }

        return true;
    }
1163637
public function bind($parameter, $value, $type = null)
    {
        $this->statement->bindParam($parameter, $value, $this->driver->getPdoType($type, $value));
        return $this;
    }
59965
public function setValue($value, $type = null)
    {
        $this->value = $value;
        $this->type  = $type ?: ParameterTypeInferer::inferType($value);
    }
513486
public function bindParam($param, &$value, $type=null, $leng=null, $driver=null)
    {
        $ok = false;
        try {
            $param = $this->_getBindVar($param);
            if ($type && $leng) {
                $ok = \oci_bind_by_name($this->_stmt, $param, $value, $leng, $this->_pdoToOciType($type));
            } else {
                $ok = \oci_bind_by_name($this->_stmt, $param, $value);
            }
            $this->_binds[$param] = $value;
        } catch (\Exception $e) {
            throw new \PDOException($e->getMessage());
        }
        return $ok;
    }
1261530
private function applyFilter(Builder $query, $field, $filter, $or = false)
    {
        $filter = explode(':', $filter);
        if (count($filter) > 1) {
            $operator = $this->getFilterOperator($filter[0]);
            $value = $this->replaceWildcards($filter[1]);
        }
        else {
            $operator = '=';
            $value = $this->replaceWildcards($filter[0]);
        }

        $fields = explode('.', $field);
        if (count($fields) > 1) {
            return $this->applyNestedFilter($query, $fields, $operator, $value, $or);
        }
        else {
            return $this->applyWhereClause($query, $field, $operator, $value, $or);
        }
    }
411268
public function whereGreaterThan($column, $value, $filter = false)
    {
        return $this->where($column, '>', $value, $filter);
    }
5792
public function filterGte(string $field, $value): self
    {
        $this->filters[] = new IndexQueryFilter($field, IndexQueryFilterOperator::GREATER_THAN_OR_EQUAL_TO(), $value);
        return $this;
    }
657855
protected function applySimpleFilter(Filter $filter)
    {
        $value = (array) $filter->getValue();
        if (count($value) > 1) {
            $this->query->whereIn($filter->getField(), $value);
        } else {
            $this->query->where($filter->getField(),
                $filter->getOperator(), $value[0]);
        }
    }
632350
public function set($key, $value, $type=null) {
		if($type === null)
			$res = serialize($value);
		else {
			$res = serialize(array(
				'_dataType' => $type,
				'input' => $this->types[$type][0]($value)
			));
		}
		$dal = $this->db->dal();
		if(!$dal->from($this->getTable())->where('key', $key)->update(array('value'=>$res)))
			$dal->into($this->getTable())->insert(array('key'=>$key, 'value'=>$res));
	}
881546
public function where($field, $table, $value) {
        static $i = 0;
        $sql = self::resolve_field($field, $table) . ' ';

        if ($value === null) {
            $sql .= 'IS NULL';

        } else {
            $param = 'where' . $i++;
            $sql .= " = :$param";
            $this->params[$param] = $value;
        }

        $this->where[] = $sql;
    }
1184425
public function setType($type = 'string')
    {
        if (!\in_array($type, $this->validTypes, true)) {
            throw new InvalidQueryParameterTypeException($type, $this->validTypes);
        }

        $this->type = $type;
    }
134479
protected static function execFilterQueue($value, array $queue, $type) {
        foreach($queue as $filter) {
            $value = self::executeValueMethod($value, $filter, $type, "filter");

            if($value === self::ERR_INVALID)
                return false;
        }
        return $value;
    }
683325
public function setParameter($parameter, $value, $type = null)
    {
        $this->parameters[$parameter] = $value;

        if ($type !== null) {
            $this->parameterTypes[$parameter] = $type;
        }

        if (is_int($parameter)) {
            $this->mode = self::MODE_POSITIONAL;
            $this->parameterCounters['positional']++;
        } else {
            $this->mode = self::MODE_NAMED;
        }

        return $this;
    }
781469
public function setFilter(
        string $field,
        $data,
        string $mode = null,
        array $selected = [],
        string $class = '',
        string $style = '',
        string $placeholder = '',
        string $url = ''
    ): ColumnInterface {
        $mode = $mode ? $mode : self::FILTER_TYPE_SELECT;
        $this->filter = [
            self::FILTER_KEY_NAME        => $field,
            self::FILTER_KEY_DATA        => $data,
            self::FILTER_KEY_MODE        => $mode,
            self::FILTER_KEY_SELECTED    => $selected,
            self::FILTER_KEY_CLASS       => $class,
            self::FILTER_KEY_STYLE       => $style,
            self::FILTER_KEY_PLACEHOLDER => $placeholder,
            self::FILTER_KEY_WIDTH       => '180px',
            self::FILTER_KEY_FORMAT      => 'DD MMM YY',
        ];
        $this->setUrl($url);

        return $this;
    }
1154636
public function buildQuery($type, $field = null, $extra = null)
    {
        if($type == 'select') {
            if($field == null) {
                $field = "*";
            }
            elseif(is_array($field)) {
                foreach($field as $i => $value) {
                    $field[$i] = '`'.trim($value).'`';
                }
                $field = trim(implode(' ,', $field));
            }
            $ex = '';
            if($extra != null && is_array($extra)) {
                foreach($extra as $i => $v) {
                    if($i == 'count') {
                        $ex .= 'COUNT';
                        if($v == null) {
                            $ex .= '(*)';
                        }
                    }
                    if($i == 'field') {
                        $ex .= ' as `'.$v.'`';
                    }
                }
                $sql = "SELECT $ex FROM `".$this->getTable().'` '.$this->where;
            }
            else {
                $sql = "SELECT $field FROM `".$this->getTable().'` '.$this->where.$this->order.$this->limit;
            }
        }
        elseif($type == 'insert') {
            if(is_array($field)) {
                $keys = array_keys($field);
                if($keys[0] === 0) {
                    $keys = '';
                }
                else {
                    foreach($keys as $i => $key) {
                        $keys[$i] = ' `'.trim($key).'`';
                    }
                    $keys = implode(',', $keys);
                }
                $values = array_values($field);
                foreach($values as $i => $val) {
                    $values[$i] = is_string($val) ? "'$val'" : $val;
                }
                $values = implode(' ,', $values);
            }
            else {
                $keys = '';
                $values = trim($field);
            }
            $values = "($values)";
            $keys = ($keys !== '') ? "($keys)" : '';
            $sql = "INSERT INTO `".$this->getTable()."` $keys VALUES $values".$this->duplicateUpdate;
        }
        elseif($type == 'update') {
            if(is_array($field)) {
                foreach($field as $key => $value) {
                    $values[] = " `$key` = ".(is_string($value) ? "'$value'" : $value);
                }
                $values = implode(' ,', $values);
            }
            else {
                $values = trim($field);
            }
            $sql = "UPDATE `".$this->getTable()."` SET $values ".$this->where;
        }
        elseif($type == 'delete') {
            $sql = "DELETE FROM `".$this->getTable()."` ".$this->where;
        }
        $this->query = $sql;
        return $sql;
    }
729123
public static function registerFilter(string $type, $filter)
    {
        if (gettype($type) !== 'string') {
            return;
        }
        if (!isset(self::$filters[$type])) {
            self::$filters[$type] = [];
        }
        self::$filters[$type][] = $filter;
    }
130275
protected function _buildQuery(Query $query, $field, $value, array $data = [])
    {
        $type = $this->config('type');
        $value = '%' . $value . '%';
        $fields = $this->config('fields');
        $typesMap = $this->config('fieldTypes');
        $types = [];
        foreach ($fields as $field) {
            if (is_array($typesMap) && array_key_exists($field, $typesMap)) {
                $types[$field] = $typesMap[$field];
            } else {
                $types[$field] = null;
            }
        }
        if (empty($type)) {
            $type = 'and';
        }

        return $query->where(function ($exp) use (&$query, $value, $type, $fields, $types) {
            return $exp->{$type . '_'}(function ($ex) use ($value, $fields, $types) {
                collection($fields)->each(function ($field) use ($value, &$ex, $types) {
                    return $ex->like($field, $value, $types[$field]);
                });

                return $ex;
            });
        });
    }