Generate query that selects ids of visible URLs.

@param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
@return \eZ\Publish\Core\Persistence\Database\SelectQuery
321017
protected function getVisibleOnlySubQuery(SelectQuery $query)
    {
        // TODO: The following query requires optimization
        $subSelect = $query->subSelect();
        $subSelect
            ->selectDistinct('ezurl_object_link.url_id')
            ->from('ezurl_object_link')
            ->innerJoin(
                'ezcontentobject_attribute',
                $query->expr->lAnd(
                    $query->expr->eq('ezurl_object_link.contentobject_attribute_id', 'ezcontentobject_attribute.id'),
                    $query->expr->eq('ezurl_object_link.contentobject_attribute_version', 'ezcontentobject_attribute.version')
                )
            )
            ->innerJoin(
                'ezcontentobject_tree',
                $query->expr->lAnd(
                    $query->expr->eq('ezcontentobject_tree.contentobject_id', 'ezcontentobject_attribute.contentobject_id'),
                    $query->expr->eq('ezcontentobject_tree.contentobject_version', 'ezcontentobject_attribute.version')
                )
            )
            ->where(
                $query->expr->eq(
                    'ezcontentobject_tree.is_invisible',
                    $query->bindValue(0, null, PDO::PARAM_INT)
                )
            );

        return $subSelect;
    }
197366
public function build(&$query)
    {
        if (isset($query['alias']) && isset($query['id'])) {
            $query['id'] = $query['id'].'-'.$query['alias'];
            unset($query['alias']);
        }

        $segments = array();

        if (isset($query['oid'])) {
            if ($query['oid'] == 'viewer') {
                $query['oid'] = get_viewer()->uniqueAlias;
            }
            $segments[] = '@'.$query['oid'];
            unset($query['oid']);
        }

        $segments = array_merge($segments, parent::build($query));

        return $segments;
    }
331268
public function visitSelect(\Aztech\Skwal\Query\Select $query)
    {
        $assembler = new \Aztech\Skwal\Visitor\Printer\Assembler\Select();
        
        $this->appendSelectList($assembler, $query);
        $this->appendFromClause($assembler, $query);
        $this->appendWhereClauseIfNecessary($assembler, $query);
        $this->appendGroupByList($assembler, $query);
        $this->appendOrderByList($assembler, $query);
        
        $this->queryStack->push($assembler->getAssembledStatement());
    }
1040084
protected function applyFilters(\SelectQuery $select, Query $query)
    {
        if ($query->has('status')) {
            $select->condition('n.status', $query->get('status'));
        }
        if ($query->has('promote')) {
            $select->condition('n.promote', $query->get('promote'));
        }
        if ($query->has('sticky')) {
            $select->condition('n.sticky', $query->get('sticky'));
        }
        if ($query->has('type')) {
            $select->condition('n.type', $query->get('type'));
        }
    }
515996
public function search($query)
  {
    $content = $query->getBridgeJson($this->clientKey);

    return $this->query($this->bridgeUrl, $content, self::RESULTS_CLASS);
  }
1021619
protected function verifyLimits (SelectQuery $query) {
        if (empty($query->getLimit())) {
            $query->limit($this->getDefaultLimit());

        } else if ($query->getLimit() > $this->getMaxLimit()) {
            $query->limit($this->getMaxLimit());
        }
    }
795417
protected function _selectQueryTranslator($query)
    {
        $limit = $query->clause('limit');
        $offset = $query->clause('offset');

        if ($limit && $offset === null) {
            $query->modifier(['_auto_top_' => sprintf('TOP %d', $limit)]);
        }

        if ($offset !== null && !$query->clause('order')) {
            $query->order($query->newExpr()->add('(SELECT NULL)'));
        }

        if ($this->_version() < 11 && $offset !== null) {
            return $this->_pagingSubquery($query, $limit, $offset);
        }

        return $this->_transformDistinct($query);
    }
49656
public static function filterQueryOrFragment($query)
    {
        if (!\is_string($query)) {
            throw new \InvalidArgumentException('Uri query string and fragment must be a string');
        }

        return preg_replace_callback(
            '/(?:[^a-zA-Z0-9_\-\.~!\$&\'\(\)\*\+,;=%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/u',
            function ($match) {
                return rawurlencode($match[0]);
            },
            $query
        ) ?? '';
    }
555410
protected function loadData(SelectQuery $query, $bulkCount, $pass)
    {
        $query->limit($bulkCount, $pass * $bulkCount);

        $stmt = $query->prepare();
        $stmt->execute();

        return $stmt->fetchAll(PDO::FETCH_ASSOC);
    }
1042739
protected function addSelectsToQuery(Builder $query, array $selects)
    {
        if (!empty($selects)) {
            $query->selectRaw('max(' . implode(' + ', $selects) . ') as relevance', $this->searchBindings);
        }
    }
1062513
public function select(...$select): Query\Select
    {
        $query = new Query\Select();
        $query->select(...$select);
        return $query;
    }
974813
public function withQuery($query)
    {
        if (!is_string($query) && !method_exists($query, '__toString')) {
            throw new \InvalidArgumentException('Query string must be a string');
        }
        $query = (string) $query;
        if (strpos($query, '?') === 0) {
            $query = substr($query, 1);
        }
        $query = $this->filterQueryAndFragment($query);

        $new = clone $this;
        $new->query = $query;

        return $new;
    }
1264898
public function selectOne($query, $bindings = array())
    {
        $query .= " LIMIT 1;";
        $result = $this->select($query, $bindings);
        return (isset($result[0]) ? $result[0] : []);
    }
942322
public function copyTo(Select $query)
    {
        $query->fields = $this->fields;
        $query->distinct = $this->distinct;
        $query->orders = $this->orders;
        $query->groups = $this->groups;
        $query->joins = $this->joins;
        $query->groupResults = $this->groupResults;
        $query->forwardKey = $this->forwardKey;
    }
334380
public function xpath($query)
    {
        $nodes = [];
        /**
         * @var \DOMNode $node
         */
        foreach ($this->_document->getQuery()->xpath($query, $this->_node) as $node) {
            $nodes[$node->getNodePath()] = $node;
        }
        return new SelectorList($this->_document, $nodes);
    }
1227802
public function search($query) {
        $found = array();

        foreach ($this->settings as $setting) {
            if ($setting->is_related($query)) {
                $found[] = $setting;
            }
        }

        if ($found) {
            $result = new stdClass();
            $result->page     = $this;
            $result->settings = $found;
            return array($this->name => $result);
        }

        $found = false;
        if (strpos(strtolower($this->name), $query) !== false) {
            $found = true;
        } else if (strpos(core_text::strtolower($this->visiblename), $query) !== false) {
                $found = true;
            }
        if ($found) {
            $result = new stdClass();
            $result->page     = $this;
            $result->settings = array();
            return array($this->name => $result);
        } else {
            return array();
        }
    }
892313
protected function configureQuery(SelectQuery $query, bool $loadColumns = true): SelectQuery
    {
        //Clarifying table name
        $query->from("{$this->getTable()} AS {$this->getAlias()}");

        //Columns to be loaded for primary model
        if ($loadColumns) {
            $this->mountColumns($query, true, '', true);
        }

        return parent::configureQuery($query, $loadColumns);
    }