Shortcut to construct a FQuery
@return SelectBuilder
551993
public static function faceQueryBuilder(Config $config = null)
    {
        if(null == $config) {
            return new SelectBuilder(self::getEntityFace());
        }else{
            return new SelectBuilder(self::getEntityFace($config->getFaceLoader()));
        }
    }
750312
private function buildSelect()
	{
		$selects = [];

		foreach ($this->select as $select)
		{
			$string = ($select['count']) ? "COUNT({$select['column']})" : $select['column'];

			// See if we're including an alias
			if (isset($select['as']))
			{
				$string .= " AS {$select['as']}";
			}

			// @FIXME: not quoting name here because we could have a function here as well
			// $selects[] = $this->connection->quoteName($string, $select['as']);
			$selects[] = $string;
		}

		return 'SELECT ' . implode(',', $selects);
	}
752335
private String buildQuery() {
        fetchKeys();

        List<String> columns = getSelectColumns();
        String selectColumnList = columns.size() == 0 ? "*" : makeColumnList(columns);
        String partitionKeyList = makeColumnList(partitionKeys);

        return String.format("SELECT %s FROM %s.%s WHERE token(%s)>? AND token(%s)<=?" + getAdditionalWhereClauses(),
                selectColumnList, quote(keyspace), quote(cfName), partitionKeyList, partitionKeyList);
    }
531894
private function getSelectQuery()
    {
        return 'SELECT '.(empty($this->parts['select']) ? '*' : implode(', ', $this->parts['select'])).
               ' FROM '.$this->getFromClause().
               (($this->parts['where'] !== null) ? ' WHERE '.$this->parts['where'] : null).
               (!empty($this->parts['group_by']) ? ' GROUP BY '.implode(', ', $this->parts['group_by']) : null).
               (($this->parts['having'] !== null) ? ' HAVING '.$this->parts['having'] : null).
               (!empty($this->parts['order_by']) ? ' ORDER BY '.implode(', ', $this->parts['order_by']) : null).
               (($this->parts['limit'] !== null) ? ' LIMIT '.$this->parts['limit'] : null).
               (($this->parts['offset'] !== null) ? ' OFFSET '.$this->parts['offset'] : null);
    }
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;
	}
775981
public function compileSelect()
    {

        // Compile "Select From"
        if (sizeof($this->query->getQuerySelect()) == 0) {
            $this->queryString = 'SELECT * ';

            return;
        }

        foreach ($this->query->getQuerySelect() as $key => $value) {
            if ($value instanceof Raw) {
                $value = $value->getString();
            }

            if ($key == 0) {
                $selectString = "$value";
            } else {
                $selectString .= ",$value";
            }
        }

        $this->queryString = "SELECT $selectString";
    }
752590
public function GetSelect() {
      // Close off any open query elements.
      $this->_EndQuery();
      
      $Sql = (!$this->_Distinct) ? 'select ' : 'select distinct ';

      // Don't escape the field if it is numeric or an asterisk (all columns)
      $Selects = array();
      foreach($this->_Selects as $Key => $Expr) {
         $Field = $Expr['Field'];
         $Function = $Expr['Function'];
         $Alias = $Expr['Alias'];
         $CaseOptions = ArrayValue('CaseOptions', $Expr);
         if ($Field != '*' && !is_numeric($Field))
            $Field = $this->EscapeIdentifier($Field);

         if ($Alias == '' && $Function != '')
            $Alias = $Field;

         // if (in_array(strtolower($Function), array('max', 'min', 'avg', 'sum', 'count')))
         if ($Function != '') {
				if(strpos($Function, '%s') !== FALSE)
					$Field = sprintf($Function, $Field);
				else
					$Field = $Function.'('.$Field.')';
			}

         if ($CaseOptions !== FALSE)
            $Field = 'case ' . $Field . $CaseOptions . ' end';

         if ($Alias != '')
            $Field .= ' as '.$this->QuoteIdentifier($Alias);

         if ($Field != '')
            $Selects[] = $Field;
      }
      $Sql .= (count($Selects) == 0) ? '*' : implode(', ', $Selects);

      if (count($this->_Froms) > 0)
         $Sql .= "\nfrom ".$this->_FromTables($this->_Froms);

      if (count($this->_Joins) > 0) {
         $Sql .= "\n";
         $Sql .= implode("\n", $this->_Joins);
      }

      if (count($this->_Wheres) > 0)
         $Sql .= "\nwhere ";

      $Sql .= implode("\n", $this->_Wheres);

      // Close any where groups that were left open.
      for ($i = 0; $i < $this->_OpenWhereGroupCount; ++$i) {
         $Sql .= ')';
      }
      $this->_OpenWhereGroupCount = 0;

      if (count($this->_GroupBys) > 0) {
         $Sql .= "\ngroup by ";

         // special consideration for table aliases
         if (count($this->_AliasMap) > 0 && $this->Database->DatabasePrefix)
            $Sql .= implode(', ', $this->_FilterTableAliases($this->_GroupBys));
         else
            $Sql .= implode(', ', $this->_GroupBys);
      }

      if (count($this->_Havings) > 0)
         $Sql .= "\nhaving ".implode("\n", $this->_Havings);

      if (count($this->_OrderBys) > 0)
         $Sql .= "\norder by ".implode(', ', $this->_OrderBys);

      if (is_numeric($this->_Limit)) {
         $Sql .= "\n";
         $Sql = $this->GetLimit($Sql, $this->_Limit, $this->_Offset);
      }

      return $Sql;
   }
154699
public function buildQuery()
    {
        $this->setSelectFrom();
        $this->setLeftJoins($this->qb);
        $this->setWhere($this->qb);
        $this->setWhereResultCallback($this->qb);
        $this->setWhereAllCallback($this->qb);
        $this->setOrderBy();
        $this->setLimit();

        return $this;
    }
473340
public function getQueryBuilder()
    {
        $queryBuilder = $this->entityManager->createQueryBuilder();
        $queryBuilder
            ->select('e')
            ->from($this->admin->getEntityClass(), 'e')
            ->orderBy('e.id', 'DESC');

        $expr = $queryBuilder->expr()->andX();

        /** @var DatagridFilter $filter */
        $i = 0;
        foreach ($this->filters as $filter) {
            $filterExprName = $filter->getExpression();
            // Value can be false but valid, it is only invalid when null.
            if ($filterExprName && !is_null($filter->getValue())) {
                $filterExpr = $queryBuilder->expr()->{$filterExprName}('e.'.$filter->getName(), ':param_'.$i);
                $queryBuilder->setParameter('param_'.$i, $filter->getValue());
                $expr->add($filterExpr);
                $i++;
            }
        }

        if ($expr->count() > 0) {
            $queryBuilder->where($expr);
        }

        return $queryBuilder;
    }
122636
private function getZoneSelectQuery(): QueryBuilder
    {
        $query = $this->connection->createQueryBuilder();
        $query->select('DISTINCT ngbm_zone.*')
            ->from('ngbm_zone');

        return $query;
    }
289116
public function useMinimumMatchFromTypoScript(): QueryBuilder
    {
        $searchConfiguration = $this->typoScriptConfiguration->getSearchConfiguration();
        if (!empty($searchConfiguration['query.']['minimumMatch'])) {
            return $this->useMinimumMatch($searchConfiguration['query.']['minimumMatch']);
        }

        return $this;
    }
225833
protected function createQuery()
    {
        if (!$this->queryCreated) {
            $this->setBaseQuery();
            $this->filter('fvIsApproved', 1);
            $this->setupAttributeFilters("left join FileSearchIndexAttributes on (fv.fID = FileSearchIndexAttributes.fID)");
            $this->setupFilePermissions();
            $this->setupFileSetFilters();
            $this->queryCreated = 1;
        }
    }
902269
public function useBoostFunctionFromTypoScript(): QueryBuilder
    {
        $searchConfiguration = $this->typoScriptConfiguration->getSearchConfiguration();
        if (!empty($searchConfiguration['query.']['boostFunction'])) {
            return $this->useBoostFunction($searchConfiguration['query.']['boostFunction']);
        }

        return $this;
    }
340108
public function select($fields=null)
    {
        if (func_num_args() > 1) {
            $fields = func_get_args();
        }
        $this->getQuery()->type('select')->fields($fields);
        return $this;
    }
910463
public function getQueryBuilder()
    {
        if ( ! $this->queryBuilder instanceof AbstractQueryBuilder) {
            $className = str_replace('Connection', 'QueryBuilder', get_called_class());

            if (class_exists($className)) {
                $this->queryBuilder = new $className($this);
            }
        }

        return $this->queryBuilder;
    }
876019
public function select(Sql\Query\FQuery $fQuery, $useGlobalInstanceKeeper = false)
    {
        $statement=$fQuery->execute($this->config->getPdo());

        if($useGlobalInstanceKeeper){
            $instanceKeeper = $this->instancesKeeper;
        }else{
            $instanceKeeper = new InstancesKeeper();
        }

        if (!$statement->rowCount()) {
            return new ResultSet($fQuery->getBaseFace(), $instanceKeeper);
        }

        $hydrator = new ArrayHydrator();
        $rs = $hydrator->hydrate($fQuery, $statement);
        return $rs;
    }
1047378
public static function select()
    {
        try {
            self::init();
            $columns = func_get_args();
            $query = 'SELECT ' . implode(', ', $columns) . ' FROM ' . self::$modelTable;
            return new QueryBuilder(self::$connect, $query);

        } catch (\Exception $exception) {
            var_dump($exception->getMessage());
        }
    }