Builds the query with the given category.

@return Builder
353329
public function query() : Builder
	{
		if (is_null($this->category_id)) {
			return $this->builder;
		}

		if (count($children = $this->children()) > 0) {
			$this->builder->whereIn('category_id', $children);
		}

		return $this->builder;
	}
533158
public function build(): QueryObjectsRequest
	{
		$instance = new QueryObjectsRequest();
		if ($this->prototypeObjectId === null) {
			throw new BuilderException('Property [prototypeObjectId] is required.');
		}
		$instance->prototypeObjectId = $this->prototypeObjectId;
		$instance->objectGroup = $this->objectGroup;
		return $instance;
	}
645476
public function buildQuery()
    {
        $model = $this->model;
        $query = $model::query();

        // perform joins
        if (is_array($this->join)) {
            foreach ($this->join as $condition) {
                list($joinModel, $column, $foreignKey) = $condition;
                $query->join($joinModel, $column, $foreignKey);
            }
        }

        // sanitze and set the filter
        $filter = $this->parseFilterInput($this->filter);
        $query->where($filter);

        // performs a search using LIKE queries
        // WARNING use sparingly, these queries are expensive
        if (!empty($this->search) && is_string($this->search) && property_exists($model, 'searchableProperties')) {
            $w = [];
            $search = addslashes($this->search);
            foreach ($model::$searchableProperties as $name) {
                $w[] = "`$name` LIKE '%$search%'";
            }

            if (count($w) > 0) {
                $query->where('('.implode(' OR ', $w).')');
            }
        }

        // eager loading
        foreach ($this->expand as $k) {
            $property = $model::getProperty($k);
            if ($property && isset($property['relation'])) {
                if (isset($property['id_property'])) {
                    $query->with($property['id_property']);
                } else {
                    $query->with($k);
                }
            }
        }

        if (isset($this->sort)) {
            $query->sort($this->sort);
        }

        // calculate limit and offset
        $start = ($this->page - 1) * $this->perPage;
        $query->start($start)->limit($this->perPage);

        return $query;
    }
799818
protected function newBaseQueryBuilder()
    {
        $conn = $this->getConnection();

        $grammar = $conn->getQueryGrammar();

        $builder = new Builder($conn, $grammar, $conn->getPostProcessor());
        $builder->cacheDriver($this->cache);

        if ($this->expire !== null) {
            $builder->remember($this->expire);
        }

        $builder->cacheTags($this->table);

        return $builder;
    }
791779
public function build(): GetSearchResultsRequest
	{
		$instance = new GetSearchResultsRequest();
		if ($this->searchId === null) {
			throw new BuilderException('Property [searchId] is required.');
		}
		$instance->searchId = $this->searchId;
		if ($this->fromIndex === null) {
			throw new BuilderException('Property [fromIndex] is required.');
		}
		$instance->fromIndex = $this->fromIndex;
		if ($this->toIndex === null) {
			throw new BuilderException('Property [toIndex] is required.');
		}
		$instance->toIndex = $this->toIndex;
		return $instance;
	}
633600
protected function newBaseQueryBuilder()
    {
        $connection = $this->getConnection();
        // Check the connection type
        if ($connection instanceof \duxet\Rethinkdb\Connection) {
            return new QueryBuilder($connection);
        }

        return parent::newBaseQueryBuilder();
    }
539287
public function setCategory($category)
    {
        $properties = $this->getProperty();
        $properties['category'] = (array) $category;
        $this->getConfig()->setSection('bundle', $properties, true);

        return $this;
    }
2239
public function buildCriteria()
    {
        $criteria = new Criteria(C2PTableMap::DATABASE_NAME);

        if ($this->isColumnModified(C2PTableMap::COL_CATEGORY_ID)) {
            $criteria->add(C2PTableMap::COL_CATEGORY_ID, $this->category_id);
        }
        if ($this->isColumnModified(C2PTableMap::COL_PAGE_ID)) {
            $criteria->add(C2PTableMap::COL_PAGE_ID, $this->page_id);
        }

        return $criteria;
    }
722460
public function buildCategoryTree()
    {
        $categories = $this
            ->categoryRepository
            ->getAllCategoriesSortedByParentAndPositionAsc();

        $categoryTree = [
            0 => null,
            'children' => [],
        ];

        /**
         * @var CategoryInterface $category
         */
        foreach ($categories as $category) {
            $parentCategoryId = 0;
            $categoryId = $category->getId();

            if (!$category->isRoot()) {
                if ($category->getParent() instanceof CategoryInterface) {
                    $parentCategoryId = $category->getParent()->getId();
                } else {

                    /**
                     * If category is not root and has no parent,
                     * don't insert it into the tree.
                     */
                    continue;
                }
            }

            if ($parentCategoryId && !isset($categoryTree[$parentCategoryId])) {
                $categoryTree[$parentCategoryId] = [
                    'entity' => null,
                    'children' => [],
                ];
            }

            if (!isset($categoryTree[$categoryId])) {
                $categoryTree[$categoryId] = [
                    'entity' => null,
                    'children' => [],
                ];
            }

            $categoryTree[$categoryId]['entity'] = $category;

            $categoryTree[$parentCategoryId]['children'][] = &$categoryTree[$categoryId];
        }

        return $categoryTree[0]['children']
            ?: [];
    }
1039076
public function buildQuery() 
    {
        $qb = $this->dataGrid->getQueryBuilder();

        if (!$qb instanceof QueryBuilder){
            throw new \InvalidArgumentException('Value must be instance of Doctrine\ORM\QueryBuilder.');
        }
        
        $options = $this->getOptions();
        
        // Is dependant grid ?
        if ($this->dataGrid->isDependentGrid()) {
            $qb->setParameter('masterGridRowId', $options['masterGridRowId']);
        }
        
        
        
        // Applying search filters
        if ($options['search'] && !empty($options['filters'])) {
            $this->applyFilters($qb, $options['filters']);
        }
        
        
        // Orders the records
        if ($options['orderBy']) {
            $qb->addOrderBy($options['orderBy'], $options['sort']);
        }
        
        if (!$this->dataGrid->isSortableEnabled() && $options['page'] && $options['records']){
            $qb->setMaxResults($options['records']);
            $qb->setFirstResult(($options['page'] - 1) * $options['records']);
        }

        $queryBuilderEvent = new QueryBuilderEvent($this->dataGrid->getName(), $qb);
        $this->dispatcher->dispatch(DataGridEvents::onQueryBuilderReady, $queryBuilderEvent);
        
        $this->setQuery($queryBuilderEvent->getQueryBuilder()->getQuery());
        
        // Getting count
        $paginator = new Paginator($this->getQuery());
        //$paginator->setUseOutputWalkers(false);
        $this->setCount($paginator->count());
        
        return $this;
    }
1227831
protected function makeQuery()
    {
        $query = $this->make();
        $this->conditionApplier->apply(new ConditionTaker($query));

        return $query;
    }
1198849
public function query() : Builder
	{
		if (trim($seed = $this->seed) !== '') {
			$this->builder->where(function ($query) use ($seed) {
				return $this->resolveQuery($query, $seed);
			});
		}

		return $this->builder;
	}
374323
protected function buildQuery()
	{
		$this->setup();

		$query = array();

		// Index always needs to be provided. _all means a cross index search.
		$query['index'] = empty($this->indices) ? '_all' : implode(',', array_values($this->indices));

		// Type is not required, will search in the entire index.
		if (!empty($this->types)) {
			$query['type'] = implode(',', array_values($this->types));
		}

		// Replace Fragments with their raw body.
		$query['body'] = $this->fragmentParser->parse($this->body);

		// Add all query string params, the SDK will only add known params to the URL.
		foreach ($this->queryStringParams as $paramName => $paramValue) {
			$query[$paramName] = $paramValue;
		}

		return $query;
	}
122367
public function query() {
        $builder = $this->getServiceLocator()->get($this->builderClassName);
        $builder->setOptions($this->options)->setServiceLocator($this->serviceLocator);
        return $builder;
    }
825225
public function getCategories()
    {
        return (new CmsCategoryQuery)
                ->join('cms_category_relation')->on('id', 'cms_category_id')
                ->where('object', 'cms_category_relation')->equals($this->_object)
                ->where('objectId', 'cms_category_relation')->equals($this->_objectId)
                ->find();
    }
849197
protected function newBaseQueryBuilder()
    {
        $connection = $this->getConnection();

        return new QueryBuilder($connection, $connection->getQueryGrammar(), $connection->getPostProcessor());
    }
305674
public function buildLdapQuery()
    {
        $lqb = new LdapQueryBuilder($this->ldap);

        if (!empty($this->attributes)) {
            $lqb->select($this->attributes);
        }

        return $lqb->from($this->schema);
    }