Returns the dql query string.

@return string

@throws MissingSelectClauseException if no select method was previously called
17414
public function getDql()
    {
        if (null === $this->selectClause) {
            throw new MissingSelectClauseException('Select clause is missing');
        }

        $eol = PHP_EOL;
        $joinRelatives = $this->joinSingleRelatives ? $this->joinRelativesClause : '';
        if ($this->leftJoinPlugins) {
            $joinRelatives .= " LEFT JOIN node.resourceType rtp{$eol}
            LEFT JOIN rtp.plugin p{$eol}";
        }
        $joinRoles = $this->leftJoinRoles ?
            "LEFT JOIN node.workspace workspace{$eol}".
            "LEFT JOIN workspace.roles role{$eol}" :
            '';
        $joinRights = $this->leftJoinRights ?
            "LEFT JOIN node.rights rights{$eol}".
            "JOIN rights.role rightRole{$eol}" :
            '';
        $joinLogs = $this->leftJoinLogs ?
            "JOIN node.logs log{$eol}".
            "JOIN log.resourceNode log_node{$eol}" :
            '';
        $dql =
            $this->selectClause.
            $this->fromClause.
            $joinRelatives.
            $joinRoles.
            $joinRights.
            $joinLogs.
            $this->joinClause.
            $this->whereClause.
            $this->groupByClause.
            $this->orderClause;

        return $dql;
    }
587187
public function getQueryString()
    {
        $dialect = Dialect::create($this->_adapter->getDialect(), $this);
        return $dialect->getSqlStatement();
    }
1085855
public function getWhereClause(string $prependQuery = ''): string
    {
        if (null === $this->whereClause) {
            $fields = $this->fieldsConfig->getFields();
            $platform = new DqlQueryPlatform($this->entityManager);
            $connection = $this->entityManager->getConnection();
            $queryGenerator = new QueryGenerator($connection, $platform, $fields);

            $this->nativePlatform = $this->getQueryPlatform($connection);
            $this->whereClause = $queryGenerator->getWhereClause($this->searchCondition);
            $this->parameters = $platform->getEmbeddedValues();
        }

        if ('' !== $this->whereClause) {
            return $prependQuery.$this->whereClause;
        }

        return '';
    }
82785
public function getSelect() {
        if ($this->fields && $this->fields != '*' && (!(is_string($this->fields) && '*' == $this->fields[0] && 'END) AS `__parentRelationKey`' == substr($this->fields, -29)))) {
            if (is_string($this->fields)) {
                return $this->fields;
            }
            $columns = array();
            foreach ($this->fields as $field) { // @TODO: column generation here.
                $columns[] = trim($field);
            }
            return implode(', ', $columns);
        }
        if ((is_string($this->fields) && '*' == $this->fields[0] && 'END) AS `__parentRelationKey`' == substr($this->fields, -29))){
            return implode(', ', $this->getAllColumnsForSelect()) . substr($this->fields, 1);
        } else {
            return implode(', ', $this->getAllColumnsForSelect());
        }
    }
161179
public function getQueryString()
    {
        $query = parent::getQueryString();
        if ($query) {
            $query .= '&';
        }

        if (!defined('REQUEST_TOKEN')) {
            throw new \RuntimeException('Request token not defined - can not append to query string.');
        }

        $query .= 'rt=' . REQUEST_TOKEN;

        return $query;
    }
774433
protected function GetSQLQueryForQueryRestrictionForActiveFilter()
    {
        $dStartValue = $this->GetActiveStartValue();
        $dEndValue = $this->GetActiveEndValue();
        $sQuery = '';
        if (false !== $dStartValue && false !== $dEndValue) {
            $sEscapedTargetTable = MySqlLegacySupport::getInstance()->real_escape_string($this->sItemTableName);
            $sEscapedTargetMLTTable = MySqlLegacySupport::getInstance()->real_escape_string('shop_article_'.$this->sItemTableName.'_mlt');
            $oShopAttribute = $this->GetFieldShopAttribute();

            $sQuery = "SELECT `{$sEscapedTargetMLTTable}`.*
                     FROM `{$sEscapedTargetTable}`
               INNER JOIN `{$sEscapedTargetMLTTable}` ON `{$sEscapedTargetTable}`.`id` = `{$sEscapedTargetMLTTable}`.`target_id`
                    WHERE ".$this->GetTargetTableNameField().' >= '.MySqlLegacySupport::getInstance()->real_escape_string($dStartValue).'
                      AND '.$this->GetTargetTableNameField().' <= '.MySqlLegacySupport::getInstance()->real_escape_string($dEndValue)."
                      AND `{$sEscapedTargetTable}`.`shop_attribute_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($oShopAttribute->id)."'";
        }

        return $sQuery;
    }
620782
public function getLastSearchWasExecutedWithEmptyQueryString()
    {
        $wasEmptyQueryString = false;
        if ($this->lastResultSet != null) {
            $wasEmptyQueryString = $this->lastResultSet->getUsedSearchRequest()->getRawUserQueryIsEmptyString();
        }

        return $wasEmptyQueryString;
    }
904407
public function getQueryString()
    {
        $requestUri = $this->getRequestUri();

        if (false !== $qPos = mb_strpos($requestUri, '?')) {
            // has query string
            return mb_substr($requestUri, $qPos + 1);
        }

        return '';
    }
537230
protected function getSelectionCriteria()
    {
        $options = $this->request->getParameters();
        $payload = $this->getPayloadData();
        $options = array_merge($options, $payload);
        $this->request->setParameters($options);

        $criteria = [
            'params' => []
        ];

        if (null !== ($value = $this->request->getParameter(ApiOptions::FIELDS))) {
            $criteria['select'] = explode(',', $value);
        } else {
            $criteria['select'] = ['*'];
        }

        if (null !== ($value = $this->request->getPayloadData(ApiOptions::PARAMS))) {
            $criteria['params'] = $value;
        }

        if (null !== ($value = $this->request->getParameter(ApiOptions::FILTER))) {
            /** @type TableSchema $schema */
            /** @noinspection PhpUndefinedMethodInspection */
            $schema = $this->getModel()->getTableSchema();
            $native = $this->convertFilterToNative($value, $criteria['params'], [], $schema->getColumns());
            $criteria['condition'] = $native['where'];
            if (is_array($native['params'])) {
                if (is_array($criteria['params'])) {
                    $criteria['params'] = array_merge($criteria['params'], $native['params']);
                } else {
                    $criteria['params'] = $native['params'];
                }
            }
            //	Add current user ID into parameter array if in condition, but not specified.
            if (false !== stripos($value, ':user_id')) {
                if (!isset($criteria['params'][':user_id'])) {
                    $criteria['params'][':user_id'] = SessionUtility::getCurrentUserId();
                }
            }
        }

        $value = intval($this->request->getParameter(ApiOptions::LIMIT));
        $maxAllowed = $this->getMaxRecordsReturnedLimit();
        if (($value < 1) || ($value > $maxAllowed)) {
            // impose a limit to protect server
            $value = $maxAllowed;
        }
        $criteria['limit'] = $value;

        // merge in possible payload options
        $optionNames = [
            ApiOptions::OFFSET,
            ApiOptions::ORDER,
            ApiOptions::GROUP,
        ];

        foreach ($optionNames as $option) {
            if (null !== $value = $this->request->getParameter($option)) {
                $criteria[$option] = $value;
            } elseif (!empty($otherNames = ApiOptions::getAliases($option))) {
                foreach ($otherNames as $other) {
                    if (null !== $value = $this->request->getParameter($other)) {
                        $criteria[$option] = $value;
                    } elseif (null !== $value = $this->request->getPayloadData($other)) {
                        $criteria[$option] = $value;
                    }
                }
            }
            if (!isset($criteria[$option]) && ((null !== $value = $this->request->getPayloadData($option)))) {
                $criteria[$option] = $value;
            }
        }

        return $criteria;
    }
357630
public function getAsQuestion()
    {
        $question = new Question($this->getQuestionText(), $this->default);
        $question->setMaxAttempts($this->maxAttempts);
        $question->setValidator(function ($value) {
            if ($this->isEmpty($value) && $this->isRequired()) {
                throw new MissingValueException("'{$this->name}' is required");
            }
            $this->validate($value);

            return $value;
        });
        $question->setAutocompleterValues($this->autoCompleterValues);

        return $question;
    }
217203
public function getStatement()
    {
        $cql = '';

        if (!$this->getFrom() || !$this->getWhere()) {
            throw new \Exception('Delete statement must contain from and where values');
        }

        $cql .= $this->getType().$this->getColumns().' FROM '.$this->getFrom().' WHERE '.$this->getWhere();

        if ($this->isIfExists()) {
            $cql .= ' IF EXISTS';
        }

        return $cql;
    }
883048
private function getAllUrlAliasesQuery(): string
    {
        $existingAliasesQueryBuilder = $this->connection->createQueryBuilder();
        $innerQueryBuilder = $this->connection->createQueryBuilder();

        return $existingAliasesQueryBuilder
            ->select('tmp.id')
            ->from(
                // nest subquery to avoid same-table update error
                '(' . $innerQueryBuilder->select('id')->from($this->table)->getSQL() . ')',
                'tmp'
            )
            ->getSQL();
    }
722822
public function QueryLanguage()
    {
        $this->lexer->moveNext();

        switch ($this->lexer->lookahead['type']) {
            case Lexer::T_SELECT:
                $statement = $this->SelectStatement();
                break;

            case Lexer::T_UPDATE:
                $statement = $this->UpdateStatement();
                break;

            case Lexer::T_DELETE:
                $statement = $this->DeleteStatement();
                break;

            default:
                $this->syntaxError('SELECT, UPDATE or DELETE');
                break;
        }

        // Check for end of string
        if ($this->lexer->lookahead !== null) {
            $this->syntaxError('end of string');
        }

        return $statement;
    }
1002377
public function getSQL()
    {
        $val = $this->owner->get($this->short_name);
        if ($this->type == 'boolean') {
            $val = $this->getBooleanValue($val);
        }
        if ($val == ''
            && !$this->mandatory
            && ($this->listData || $this instanceof Field_Reference)
            && $this->type != 'boolean'
        ) {
            $val = null;
        }

        return $val;
    }
59218
private function parseSelectQuery()
    {
        // Parse select ?
        $selectSql = Column::generateQueryString($this->query->select);

        // Parse table
        $fromSql = Table::generateQueryString($this->query->table);

        $whereSql = null;
        $whereBind = array();


        $sql = [
            'select' => $selectSql,
            'from' => $fromSql,
            'where' => $whereSql
            // TODO: Add other parts.
        ];

        $this->bind = array_merge(
            $this->bind,
            $whereBind
        );

        $this->sql = $this->combineSelectQuery($sql);
    }
1125878
public function asString()
    {
        $query = '';

        if (!empty($this->list)) {
            foreach ($this->list as $clause) {
                $query .= $clause->asString();
            }
        }

        return $query;
    }
1262840
public function getQuery()
    {
        $query = null;

        switch ($this->type) {
            case self::SELECT:
                $query = $this->getSelectQuery();
                break;
            case self::INSERT:
                $query = $this->getInsertQuery();
                break;
            case self::UPDATE:
                $query = $this->getUpdateQuery();
                break;
            case self::DELETE:
                $query = $this->getDeleteQuery();
                break;
        }

        return $query;
    }