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


PHP QueryBuilder::distinct方法代码示例

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


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

示例1: applyGreatestNPerGroupDate

 public function applyGreatestNPerGroupDate(QueryBuilder $qb)
 {
     $qb->distinct();
     $qb2 = $this->createQueryBuilder('ss')->select('MAX(ss.timestamp)')->where('DATE(ss.timestamp) = DATE(s.timestamp)');
     $qb->innerJoin($this->getEntityName(), 'sub', 'WITH', $qb->expr()->eq('s.timestamp', '(' . $qb2->getDQL() . ')'));
 }
开发者ID:redelivre,项目名称:login-cidadao,代码行数:6,代码来源:StatisticsRepository.php

示例2: makeDistinct

 public function makeDistinct()
 {
     $this->queryBuilder->distinct();
 }
开发者ID:animaltool,项目名称:webinterface,代码行数:4,代码来源:Query.php

示例3: applyJoins

 /**
  * Applies the given joins for the query builder
  *
  * @param QueryBuilder $qb
  * @param array|null   $joins
  */
 public static function applyJoins(QueryBuilder $qb, $joins)
 {
     if (empty($joins)) {
         return;
     }
     $qb->distinct(true);
     $rootAlias = self::getSingleRootAlias($qb);
     foreach ($joins as $key => $val) {
         if (empty($val)) {
             $qb->leftJoin($rootAlias . '.' . $key, $key);
         } elseif (is_array($val)) {
             if (isset($val['join'])) {
                 $join = $val['join'];
                 if (false === strpos($join, '.')) {
                     $join = $rootAlias . '.' . $join;
                 }
             } else {
                 $join = $rootAlias . '.' . $key;
             }
             $condition = null;
             $conditionType = null;
             if (isset($val['condition'])) {
                 $condition = $val['condition'];
                 $conditionType = Expr\Join::WITH;
             }
             if (isset($val['conditionType'])) {
                 $conditionType = $val['conditionType'];
             }
             $qb->leftJoin($join, $key, $conditionType, $condition);
         } else {
             $qb->leftJoin($rootAlias . '.' . $val, $val);
         }
     }
 }
开发者ID:antrampa,项目名称:platform,代码行数:40,代码来源:QueryUtils.php

示例4: 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

示例5: execute

 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     // emit listbuilder.create event
     $event = new ListBuilderCreateEvent($this);
     $this->eventDispatcher->dispatch(ListBuilderEvents::LISTBUILDER_CREATE, $event);
     $this->expressionFields = $this->getUniqueExpressionFieldDescriptors($this->expressions);
     // first create simplified id query
     // select ids with all necessary filter data
     $ids = $this->findIdsByGivenCriteria();
     // if no results are found - return
     if (count($ids) < 1) {
         return [];
     }
     // now select all data
     $this->queryBuilder = $this->em->createQueryBuilder()->from($this->entityName, $this->entityName);
     $this->assignJoins($this->queryBuilder);
     // Add all select fields
     foreach ($this->selectFields as $field) {
         $this->queryBuilder->addSelect($field->getSelect() . ' AS ' . $field->getName());
     }
     // group by
     $this->assignGroupBy($this->queryBuilder);
     // assign sort-fields
     $this->assignSortFields($this->queryBuilder);
     // use ids previously selected ids for query
     $select = $this->entityName . '.id';
     if (null !== $this->idField) {
         $select = $this->idField->getSelect();
     }
     $this->queryBuilder->where($select . ' IN (:ids)')->setParameter('ids', $ids);
     $this->queryBuilder->distinct($this->distinct);
     return $this->queryBuilder->getQuery()->getArrayResult();
 }
开发者ID:sulu,项目名称:sulu,代码行数:36,代码来源:DoctrineListBuilder.php

示例6: __wakeup

 /**
  * Recreate query builder and set state again.
  *
  * @return void
  */
 public function __wakeup()
 {
     if ($this->constraint !== null) {
         $this->queryBuilder->where($this->constraint);
     }
     if (is_array($this->orderings)) {
         $aliases = $this->queryBuilder->getRootAliases();
         foreach ($this->orderings as $propertyName => $order) {
             $this->queryBuilder->addOrderBy($aliases[0] . '.' . $propertyName, $order);
         }
     }
     if (is_array($this->joins)) {
         foreach ($this->joins as $joinAlias => $join) {
             $this->queryBuilder->leftJoin($join, $joinAlias);
         }
     }
     $this->queryBuilder->setFirstResult($this->offset);
     $this->queryBuilder->setMaxResults($this->limit);
     $this->queryBuilder->distinct($this->distinct);
     $this->queryBuilder->setParameters($this->parameters);
     unset($this->parameters);
 }
开发者ID:mkeitsch,项目名称:flow-development-collection,代码行数:27,代码来源:Query.php


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