当前位置: 首页>>代码示例>>PHP>>正文


PHP QueryBuilder::groupBy方法代码示例

本文整理汇总了PHP中Doctrine\ORM\QueryBuilder::groupBy方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::groupBy方法的具体用法?PHP QueryBuilder::groupBy怎么用?PHP QueryBuilder::groupBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ORM\QueryBuilder的用法示例。


在下文中一共展示了QueryBuilder::groupBy方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: modify

 /**
  * @param QueryBuilder $qb
  * @param string       $dqlAlias
  */
 public function modify(QueryBuilder $qb, $dqlAlias)
 {
     if ($this->dqlAlias !== null) {
         $dqlAlias = $this->dqlAlias;
     }
     $qb->groupBy(sprintf('%s.%s', $dqlAlias, $this->field));
 }
开发者ID:kgilden,项目名称:Doctrine-Specification,代码行数:11,代码来源:GroupBy.php

示例2: createQueryBuilder

 /**
  * @return \Doctrine\ORM\QueryBuilder
  */
 private function createQueryBuilder()
 {
     $this->queryBuilder = $this->em->createQueryBuilder()->from($this->entityName, $this->entityName);
     foreach ($this->getJoins() as $entity => $join) {
         switch ($join->getJoinMethod()) {
             case DoctrineJoinDescriptor::JOIN_METHOD_LEFT:
                 $this->queryBuilder->leftJoin($join->getJoin(), $entity, $join->getJoinConditionMethod(), $join->getJoinCondition());
                 break;
             case DoctrineJoinDescriptor::JOIN_METHOD_INNER:
                 $this->queryBuilder->innerJoin($join->getJoin(), $entity, $join->getJoinConditionMethod(), $join->getJoinCondition());
                 break;
         }
     }
     // set where
     if (!empty($this->whereFields)) {
         $this->addWheres($this->whereFields, $this->whereValues, self::WHERE_COMPARATOR_EQUAL);
     }
     // set where not
     if (!empty($this->whereNotFields)) {
         $this->addWheres($this->whereNotFields, $this->whereNotValues, self::WHERE_COMPARATOR_UNEQUAL);
     }
     if (!empty($this->groupByFields)) {
         foreach ($this->groupByFields as $fields) {
             $this->queryBuilder->groupBy($fields->getSelect());
         }
     }
     // set in
     if (!empty($this->inFields)) {
         $this->addIns($this->inFields, $this->inValues);
     }
     // set between
     if (!empty($this->betweenFields)) {
         $this->addBetweens($this->betweenFields, $this->betweenValues);
     }
     if ($this->search != null) {
         $searchParts = [];
         foreach ($this->searchFields as $searchField) {
             $searchParts[] = $searchField->getSelect() . ' LIKE :search';
         }
         $this->queryBuilder->andWhere('(' . implode(' OR ', $searchParts) . ')');
         $this->queryBuilder->setParameter('search', '%' . $this->search . '%');
     }
     return $this->queryBuilder;
 }
开发者ID:kriswillis,项目名称:sulu,代码行数:47,代码来源:DoctrineListBuilder.php

示例3: returnFilteredEntities

 /**
  * @param QueryBuilder $builder
  * @param AbstractFilter $filter
  * @param $groupBy
  *
  * @return array|Paginator
  */
 public function returnFilteredEntities(QueryBuilder $builder, AbstractFilter $filter, $groupBy)
 {
     $pagination = $filter->getPagination();
     if ($pagination->getLimit()) {
         $builder->setMaxResults($pagination->getLimit());
     }
     $builder->setFirstResult($pagination->getOffset());
     if ($pagination->isEnabled()) {
         $query = $builder->getQuery();
         $query->setHydrationMode($filter->getHydrationMode());
         $paginator = new Paginator($query, true);
         $pagination->setTotalResults(count($paginator));
         return $paginator;
     }
     $builder->groupBy($groupBy);
     $query = $builder->getQuery();
     $entities = $query->getResult($filter->getHydrationMode());
     return $entities;
 }
开发者ID:wucdbm,项目名称:wucdbm-bundle,代码行数:26,代码来源:AbstractRepository.php

示例4: getCountFilteredResults

 /**
  * Query results after filtering.
  *
  * @param integer $rootEntityIdentifier
  * @param bool    $buildQuery
  *
  * @return int
  */
 private function getCountFilteredResults($rootEntityIdentifier, $buildQuery = true)
 {
     if (true === $buildQuery) {
         $qb = $this->em->createQueryBuilder();
         $qb->select('count(distinct ' . $this->tableName . '.' . $rootEntityIdentifier . ')');
         $qb->from($this->entity, $this->tableName);
         $this->setLeftJoins($qb);
         $this->setWhere($qb);
         $this->setWhereAllCallback($qb);
         return (int) $qb->getQuery()->getSingleScalarResult();
     } else {
         $this->qb->setFirstResult(null)->setMaxResults(null)->select('count(distinct ' . $this->tableName . '.' . $rootEntityIdentifier . ')');
         if (true === $this->isPostgreSQLConnection) {
             $this->qb->groupBy($this->tableName . '.' . $rootEntityIdentifier);
             return count($this->qb->getQuery()->getResult());
         } else {
             return (int) $this->qb->getQuery()->getSingleScalarResult();
         }
     }
 }
开发者ID:robinvliz,项目名称:DatatablesBundle,代码行数:28,代码来源:DatatableQuery.php

示例5: getDataQuery

 /**
  * Build the data query
  *
  * @return QueryBuilder
  */
 public function getDataQuery()
 {
     $this->buildFilteredQuery();
     if ($this->offset !== null) {
         $this->currentQueryBuilder->setFirstResult($this->offset);
     }
     if ($this->length !== null) {
         $this->currentQueryBuilder->setMaxResults($this->length);
     }
     if ($this->orders !== null) {
         foreach ($this->orders as $order) {
             list($column, $dir) = $order;
             $this->currentQueryBuilder->addOrderBy($column->sourceSort, $dir);
         }
     }
     if (isset($this->conf->group)) {
         $this->currentQueryBuilder->groupBy($this->conf->group);
     }
     return $this->currentQueryBuilder;
 }
开发者ID:solire,项目名称:trieur,代码行数:25,代码来源:DoctrineOrm.php

示例6: groupBy

 /**
  * @param array $constraints
  * @param       $queryBuilder
  * @param       $alias
  */
 public function groupBy(array &$constraints, QueryBuilder $queryBuilder, $alias)
 {
     $this->ensuresHasArrayValue($constraints, 'grouping_columns');
     $groupedColumns = $constraints['grouping_columns'];
     foreach ($groupedColumns as $column) {
         $queryBuilder->groupBy($alias . '.' . $column);
     }
     unset($constraints['grouping_columns']);
 }
开发者ID:WeavingTheWeb,项目名称:devobs,代码行数:14,代码来源:QueryFactory.php

示例7: assignGroupBy

 /**
  * Sets group by fields to querybuilder.
  *
  * @param QueryBuilder $queryBuilder
  */
 protected function assignGroupBy($queryBuilder)
 {
     if (!empty($this->groupByFields)) {
         foreach ($this->groupByFields as $fields) {
             $queryBuilder->groupBy($fields->getSelect());
         }
     }
 }
开发者ID:ollietb,项目名称:sulu,代码行数:13,代码来源:DoctrineListBuilder.php

示例8: setGroupBy

 /**
  * set query group
  * 
  * @param string $group
  * 
  * @return Datatable 
  */
 public function setGroupBy($group)
 {
     $this->queryBuilder->groupBy($group);
     return $this;
 }
开发者ID:tiraeth,项目名称:AliDatatableBundle,代码行数:12,代码来源:DoctrineBuilder.php

示例9: applyGroupBy

 private function applyGroupBy(QueryBuilderFilter $filter, QueryBuilder $queryBuilder)
 {
     if ($filter->getGroupBy()) {
         $queryBuilder->groupBy($filter->getGroupBy());
     }
 }
开发者ID:netucz,项目名称:slovicka,代码行数:6,代码来源:QueryBuilderFilterApplier.php

示例10: getGroupByStatement

 /**
  * Group By
  * @param \Doctrine\ORM\QueryBuilder $queryBuilder
  * @param array $request
  */
 private function getGroupByStatement(\Doctrine\ORM\QueryBuilder $queryBuilder)
 {
     if ($this->groupBy !== '') {
         $queryBuilder->groupBy($this->groupBy);
     }
 }
开发者ID:SylvainSimon,项目名称:Metinify,代码行数:11,代码来源:DataTable.php

示例11: prepareCndPaGroupBy

 /**
  * Prepare certain search condition
  *
  * @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare
  * @param string                     $value        Parameter for GROUP BY
  *
  * @return void
  */
 protected function prepareCndPaGroupBy(\Doctrine\ORM\QueryBuilder $queryBuilder, $value)
 {
     $queryBuilder->groupBy($value);
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:12,代码来源:Product.php

示例12: parse

 /**
  * {@inheritdoc}
  */
 public function parse($value, QueryBuilder $qb)
 {
     if (!is_array($value)) {
         $value = Yaml::parse($value);
     }
     $processor = new Processor();
     $value = $processor->processConfiguration(new QueryConfiguration(), $value);
     if (!isset($value['from'])) {
         throw new \RuntimeException('Missing mandatory "from" section');
     }
     foreach ((array) $value['from'] as $from) {
         $qb->from($from['table'], $from['alias']);
     }
     if (isset($value['select'])) {
         foreach ($value['select'] as $select) {
             $qb->add('select', new Expr\Select($select), true);
         }
     }
     if (isset($value['distinct'])) {
         $qb->distinct((bool) $value['distinct']);
     }
     if (isset($value['groupBy'])) {
         $qb->groupBy($value['groupBy']);
     }
     if (isset($value['having'])) {
         $qb->having($value['having']);
     }
     $this->addJoin($qb, $value);
     $this->addWhere($qb, $value);
     $this->addOrder($qb, $value);
     return $qb;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:35,代码来源:YamlConverter.php


注:本文中的Doctrine\ORM\QueryBuilder::groupBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。