Builds WHERE clause for the query.

@param KDatabaseQueryInterface $query
332723
protected function _buildQueryWhere(KDatabaseQueryInterface $query)
    {
        parent::_buildQueryWhere($query);

        $state = $this->getState();

        if ($state->application) {
            $query->where('tbl.application = :application')->bind(array('application' => $state->application));
        }

        if ($state->type) {
            $query->where('tbl.type = :type')->bind(array('type' => $state->type));
        }

        if ($state->package) {
            $query->where('tbl.package IN :package')->bind(array('package' => (array) $state->package));
        }

        if ($state->name) {
            $query->where('tbl.name = :name')->bind(array('name' => $state->name));
        }

        if ($state->action) {
            $query->where('tbl.action IN (:action)')->bind(array('action' => $state->action));
        }

        if ($state->row) {
            $query->where('tbl.row IN (:row)')->bind(array('row' => $state->row));
        }

        if ($state->start_date && $state->start_date != '0000-00-00')
        {
            $start_date = $this->getObject('lib:date',array('date' => $state->start_date));

            $query->where('DATE(tbl.created_on) >= :start')->bind(array('start' => $start_date->format('Y-m-d')));

            if (is_numeric($state->day_range)) {
                $query->where('DATE(tbl.created_on) <= :range_start')->bind(array('range_start' => $start_date->modify(sprintf('+%d days', $state->day_range))->format('Y-m-d')));
            }
        }

        if ($state->end_date && $state->end_date != '0000-00-00')
        {
            $end_date  = $this->getObject('lib:date',array('date' => $state->end_date));

            $query->where('DATE(tbl.created_on) <= :end')->bind(array('end' => $end_date->format('Y-m-d')));

            if (is_numeric($state->day_range)) {
                $query->where('DATE(tbl.created_on) >= :range_end')->bind(array('range_end' => $end_date->modify(sprintf('-%d days', $state->day_range))->format('Y-m-d')));
            }
        }

        if (is_numeric($state->user)) {
            $query->where('tbl.created_by = :created_by')->bind(array('created_by' => $state->user));
        }

        if ($ip = $state->ip) {
            $query->where('tbl.ip IN (:ip)')->bind(array('ip' => $state->ip));
        }
    }
582766
protected function setPageFrom( QueryInterface $query )
    {
        if ( $this->pageFromPk )
        {
            $class = $this->query->modelClass;
            $pks = $class::primaryKey();
            if ( count($pks) > 1) {
                throw new NotSupportedException('The "page-from-pk" filter can not be apply for composite primary key.');
            }
            $query->andWhere(['<', $pks[0], $this->pageFromPk]);
        }
        return $query;
    }
959631
public function makeQueryFiltered($query)
    {
        $settingTarget = $this->getSettingTarget();
        if ($settingTarget) {
            $query = $query->where([
                ['settable_id', '=', $settingTarget->getKeyName()],
                ['settable_type', '=', $settingTarget->getMorphClass()]
            ]);
        } else {
            $query = $query->whereNull('settable_id')->whereNull('settable_type');
        }
        return $query;
    }
749961
private function applyConditions(QueryBuilder $query, array $conditions): void
    {
        foreach ($conditions as $identifier => $value) {
            $query->andWhere(
                $query->expr()->eq($identifier, ':' . $identifier)
            );

            $query->setParameter($identifier, $value, is_int($value) ? Type::INTEGER : Type::STRING);
        }
    }
354574
protected function whereNested(Builder $query, $where)
    {
        $nested = $where['query'];

        return '('.substr($this->compileWheres($nested), 6).')';
    }
89149
protected function applyWhere(Builder $query, array $where)
    {
        foreach ($where as $key => $value) {
            if (is_null($value)) {
                $query = $query->whereNull($key);
            } else {
                if (is_array($value)) {
                    $query = $query->where($key, $value[0], $value[1]);
                } else {
                    $query = $query->where($key, '=', $value);
                }
            }
        }

        return $query;
    }
781880
public function addToQuery(&$query)
    {
        parent::addToQuery($query);

        foreach ($this->compositeDatabaseFields() as $field => $spec) {
            $table = $this->getTable();
            $key = $this->getName() . $field;
            if ($table) {
                $query->selectField("\"{$table}\".\"{$key}\"");
            } else {
                $query->selectField("\"{$key}\"");
            }
        }
    }
1306451
protected function parseQuery(QueryInterface $query) {
        $operationList = $query->getStoredQueryCriteria();
        $pos = 0;
        foreach ($operationList as $operation) {
            if($pos > 0) {
                $this->addSeparator(true);
            }
            $this->parseOperation($operation);
            $pos++;
            
        }
        return $this;
    }
380455
protected function query(QueryInterface $query)
    {
        $metadata = $this->getClassMetadata();

        foreach ($metadata->getFieldMappings() as $field) {
            $fieldtype = $this->getFieldManager()->get($field['fieldtype'], $field);
            if ($fieldtype instanceof FieldTypeInterface) {
                $fieldtype->query($query, $metadata);
            }
        }
    }
623702
public function process(QueryInterface $query)
    {
        if (!$query instanceof ShowQuery || $query->getObject() !== ShowQuery::EXPRESSION_TABLE_STATUS) {
            return null;
        }

        $likeExpr = $query->getLikeExpression();
        $tablet = $this->tablet->getTablet();
        $command = new GetSchema($tablet->getAlias());
        /* @var $vtCtldResult GetSchemaResult */
        $vtCtldResult = $this->client->executeCommand($command);

        return new TableStatus($vtCtldResult, $likeExpr);
    }
508065
protected function _logQuery(Query $query, LoggerInterface $logger)
    {
        if (!$this->getDriver()->isQueryLoggingEnabled()) {
            return;
        }

        $logger->debug($query->endpoint(), [
            'params' => $query->where()
        ]);
    }
732978
protected function buildQuery(Builder $query, $name)
    {
        $op = $this->getOperator();
        $value = $this->getValue();

        switch ($op) {
            case 'in':
                $query->whereIn($name, (array) $value);
                break;
            case 'between':
                $query->whereBetween($name, (array) $value);
                break;
            case 'like':
                $value .= '%';
                $query->where($name, $op, $value);
                break;
            default:
                $query->where($name, $op, $value);
        }
    }
1375049
private function whereSearch(Builder $query, $field, array $search_terms): void
    {
        if ($field instanceof Expression) {
            $field = $field->getValue();
        }

        foreach ($search_terms as $search_term) {
            $query->whereContains(DB::raw($field), $search_term);
        }
    }
19893
public function buildSqlQuery(IndexQueryInterface $query, array $columns = null)
    {
        $queryString = sprintf("SELECT `%s` FROM `%s`", implode("`,`", $columns), $query->getName());

        if ("" !== $criteria = $this->buildSqlConditions($query)) {
            $queryString .= sprintf(" WHERE %s", $criteria);
        }

        if (null !== $limit = $query->getLimit()) {
            $queryString .= sprintf(" LIMIT %d", $limit);
        }

        return $queryString;
    }
529643
private function buildBaseQuery(
        Connection $connection,
        TableMetadata $tableMetadata,
        string $searchTerm
    ): QueryBuilder {

        // Build query except WHERE clause
        $queryBuilder = $connection
            ->createQueryBuilder()
            ->select('COUNT(*) AS count')
            ->from('`' . $tableMetadata->getDatabaseName() . '`.`' . $tableMetadata->getTableName() . '`')
            ->setParameter('search_term', '%' . $searchTerm . '%');

        foreach ($this->getSearchableColumnNames($tableMetadata) as $index => $columnName) {
            $clause = '`' . $columnName . '` LIKE :search_term';
            if (0 === $index) {
                $queryBuilder->where($clause);
            } else {
                $queryBuilder->orWhere($clause);
            }
        }

        return $queryBuilder;
    }
146437
protected function isMissingAQueryParameter(QueryInterface $query)
    {
        if (!isset($query[$this->expiresParameter])) {
            return true;
        }

        if (!isset($query[$this->signatureParameter])) {
            return true;
        }

        return false;
    }
575245
public function apply(QueryObjectInterface $query)
    {
        if (empty($this->fields)) {
            return $this;
        }
        
        $query->where(
            [
                $this->getQueryCondition() => [
                    ':pattern' => "%{$this->pattern}%"
                ]
            ]
        );
        return $this;
    }