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


PHP QueryBuilder::getRootAlias方法代码示例

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


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

示例1: addFieldSorter

 /**
  * {@inheritdoc}
  */
 public function addFieldSorter($field, $direction, $locale = null, $scope = null)
 {
     $this->qb->addOrderBy($field, $direction);
     $idField = $this->qb->getRootAlias() . '.id';
     $this->qb->addOrderBy($idField);
     return $this;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:10,代码来源:IsAssociatedSorter.php

示例2: addFieldSorter

 /**
  * {@inheritdoc}
  */
 public function addFieldSorter($field, $direction, $locale = null, $scope = null)
 {
     $alias = 'inGroupSorter';
     $inGroupExpr = 'CASE WHEN :currentGroup MEMBER OF p.groups THEN true ELSE false END';
     $this->qb->addSelect(sprintf('%s AS %s', $inGroupExpr, $alias))->addOrderBy($alias, $direction);
     $idField = $this->qb->getRootAlias() . '.id';
     $this->qb->addOrderBy($idField);
     return $this;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:12,代码来源:InGroupSorter.php

示例3: addFieldSorter

 /**
  * {@inheritdoc}
  */
 public function addFieldSorter($field, $direction, $locale = null, $scope = null)
 {
     $alias = 'sorterCompleteness';
     $util = new CompletenessJoin($this->qb);
     $util->addJoins($alias, $locale, $scope);
     $this->qb->addOrderBy($alias . '.ratio', $direction);
     $idField = $this->qb->getRootAlias() . '.id';
     $this->qb->addOrderBy($idField);
     return $this;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:13,代码来源:CompletenessSorter.php

示例4: addJoins

 /**
  * Add completeness joins to query builder
  *
  * @param string $completenessAlias the join alias
  * @param string $locale            the locale
  * @param sting  $scope             the scope
  *
  * @return CompletenessJoin
  */
 public function addJoins($completenessAlias, $locale, $scope)
 {
     $rootAlias = $this->qb->getRootAlias();
     $localeAlias = $completenessAlias . 'Locale';
     $channelAlias = $completenessAlias . 'Channel';
     $rootEntity = current($this->qb->getRootEntities());
     $completenessMapping = $this->qb->getEntityManager()->getClassMetadata($rootEntity)->getAssociationMapping('completenesses');
     $completenessClass = $completenessMapping['targetEntity'];
     $this->qb->leftJoin('PimCatalogBundle:Locale', $localeAlias, 'WITH', $localeAlias . '.code = :cLocaleCode')->leftJoin('PimCatalogBundle:Channel', $channelAlias, 'WITH', $channelAlias . '.code = :cScopeCode')->leftJoin($completenessClass, $completenessAlias, 'WITH', $completenessAlias . '.locale = ' . $localeAlias . '.id AND ' . $completenessAlias . '.channel = ' . $channelAlias . '.id AND ' . $completenessAlias . '.product = ' . $rootAlias . '.id')->setParameter('cLocaleCode', $locale)->setParameter('cScopeCode', $scope);
     return $this;
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:20,代码来源:CompletenessJoin.php

示例5: addFieldSorter

 /**
  * {@inheritdoc}
  */
 public function addFieldSorter($field, $direction)
 {
     $rootAlias = $this->qb->getRootAlias();
     $prefix = 'sorter';
     $field = $prefix . 'familyLabel';
     $family = $prefix . 'family';
     $trans = $prefix . 'familyTranslations';
     $this->qb->leftJoin($rootAlias . '.family', $family)->leftJoin($family . '.translations', $trans, 'WITH', $trans . '.locale = :dataLocale');
     $this->qb->addSelect('COALESCE(' . $trans . '.label, CONCAT(\'[\', ' . $family . '.code, \']\')) as ' . $field);
     $this->qb->addOrderBy($field, $direction);
     return $this;
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:15,代码来源:FamilySorter.php

示例6: addAttributeFilter

 /**
  * {@inheritdoc}
  */
 public function addAttributeFilter(AbstractAttribute $attribute, $operator, $value)
 {
     $joinAlias = 'filter' . $attribute->getCode() . $this->aliasCounter++;
     $backendField = sprintf('%s.%s', $joinAlias, $attribute->getBackendType());
     if ($operator === 'EMPTY') {
         $this->qb->leftJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $this->prepareAttributeJoinCondition($attribute, $joinAlias));
         $this->qb->andWhere($this->prepareCriteriaCondition($backendField, $operator, $value));
     } else {
         $condition = $this->prepareAttributeJoinCondition($attribute, $joinAlias);
         $condition .= ' AND ' . $this->prepareCriteriaCondition($backendField, $operator, $value);
         $this->qb->innerJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $condition);
     }
     return $this;
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:17,代码来源:BaseFilter.php

示例7: addAttributeSorter

 /**
  * {@inheritdoc}
  */
 public function addAttributeSorter(AttributeInterface $attribute, $direction, $locale = null, $scope = null)
 {
     $aliasPrefix = 'sorter';
     $joinAlias = $aliasPrefix . 'V' . $attribute->getCode();
     $backendType = $attribute->getBackendType();
     // join to value
     $condition = $this->prepareAttributeJoinCondition($attribute, $joinAlias, $locale, $scope);
     $this->qb->leftJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $condition);
     $joinAliasMetric = $aliasPrefix . 'M' . $attribute->getCode();
     $this->qb->leftJoin($joinAlias . '.' . $backendType, $joinAliasMetric);
     $this->qb->addOrderBy($joinAliasMetric . '.baseData', $direction);
     $idField = $this->qb->getRootAlias() . '.id';
     $this->qb->addOrderBy($idField);
     return $this;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:18,代码来源:MetricSorter.php

示例8: sort

 /**
  * Sets sorting.
  * @param array $sorting
  */
 public function sort(array $sorting)
 {
     foreach ($sorting as $key => $value) {
         $column = isset($this->sortMapping[$key]) ? $this->sortMapping[$key] : $this->qb->getRootAlias() . '.' . $key;
         $this->qb->addOrderBy($column, $value);
     }
 }
开发者ID:cujan,项目名称:vcelyweb,代码行数:11,代码来源:Doctrine.php

示例9: entityJoin

 /**
  * {@inheritdoc}
  */
 public function entityJoin(array $associationMappings)
 {
     $alias = $this->queryBuilder->getRootAlias();
     $newAlias = 's';
     $joinedEntities = $this->queryBuilder->getDQLPart('join');
     foreach ($associationMappings as $associationMapping) {
         // Do not add left join to already joined entities with custom query
         foreach ($joinedEntities as $joinExprList) {
             foreach ($joinExprList as $joinExpr) {
                 $newAliasTmp = $joinExpr->getAlias();
                 if (sprintf('%s.%s', $alias, $associationMapping['fieldName']) === $joinExpr->getJoin()) {
                     $this->entityJoinAliases[] = $newAliasTmp;
                     $alias = $newAliasTmp;
                     continue 3;
                 }
             }
         }
         $newAlias .= '_' . $associationMapping['fieldName'];
         if (!in_array($newAlias, $this->entityJoinAliases)) {
             $this->entityJoinAliases[] = $newAlias;
             $this->queryBuilder->leftJoin(sprintf('%s.%s', $alias, $associationMapping['fieldName']), $newAlias);
         }
         $alias = $newAlias;
     }
     return $alias;
 }
开发者ID:paolotremadio,项目名称:SonataDoctrineORMAdminBundle,代码行数:29,代码来源:ProxyQuery.php

示例10: getFieldName

 /**
  * {@inheritdoc}
  */
 private function getFieldName($field)
 {
     if (false === strpos($field, '.')) {
         return $this->queryBuilder->getRootAlias() . '.' . $field;
     }
     return $field;
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:10,代码来源:ExpressionBuilder.php

示例11: addAttributeSorter

 /**
  * {@inheritdoc}
  */
 public function addAttributeSorter(AbstractAttribute $attribute, $direction)
 {
     $aliasPrefix = 'sorter';
     $joinAlias = $aliasPrefix . 'V' . $attribute->getCode() . $this->aliasCounter++;
     $backendType = $attribute->getBackendType();
     // join to value and sort on
     $condition = $this->prepareAttributeJoinCondition($attribute, $joinAlias);
     // Remove current join in order to put the orderBy related join
     // at first place in the join queue for performances reasons
     $joinsSet = $this->qb->getDQLPart('join');
     $this->qb->resetDQLPart('join');
     $this->qb->leftJoin($this->qb->getRootAlias() . '.values', $joinAlias, 'WITH', $condition);
     $this->qb->addOrderBy($joinAlias . '.' . $backendType, $direction);
     // Reapply previous join after the orderBy related join
     $this->applyJoins($joinsSet);
     return $this;
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:20,代码来源:BaseSorter.php

示例12: __construct

 /**
  * @param \Doctrine\ORM\QueryBuilder $qb
  * @param string $searchfield search field for IN query, uses rootAlias.id by default [optional]
  */
 public function __construct(QueryBuilder $qb, $searchfield = null)
 {
     $this->qb = $qb;
     if (null !== $searchfield) {
         $this->searchfield = $searchfield;
     } else {
         $this->searchfield = $qb->getRootAlias() . '.id';
     }
 }
开发者ID:outeredge,项目名称:edge-zf2,代码行数:13,代码来源:IdToResultConverter.php

示例13: aliasExists

 private function aliasExists($alias, QueryBuilder $qb)
 {
     $aliases = [];
     foreach ($qb->getDqlPart('join') as $joins) {
         foreach ($joins as $join) {
             $aliases[] = $join->getAlias();
         }
     }
     $aliases[] = $qb->getRootAlias();
     return in_array($alias, $aliases);
 }
开发者ID:adampiotrowski,项目名称:DoctrineBehaviors,代码行数:11,代码来源:JoinableRepository.php

示例14: Expr

 function it_adds_a_like_filter_in_the_query(QueryBuilder $queryBuilder, AbstractAttribute $sku)
 {
     $sku->getId()->willReturn(42);
     $sku->getCode()->willReturn('sku');
     $sku->getBackendType()->willReturn('varchar');
     $sku->isLocalizable()->willReturn(false);
     $sku->isScopable()->willReturn(false);
     $queryBuilder->expr()->willReturn(new Expr());
     $queryBuilder->getRootAlias()->willReturn('p');
     $condition = "filtersku1.attribute = 42 AND filtersku1.varchar LIKE 'My Sku'";
     $queryBuilder->innerJoin('p.values', 'filtersku1', 'WITH', $condition)->shouldBeCalled();
     $this->addAttributeFilter($sku, 'LIKE', 'My Sku');
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:13,代码来源:BaseFilterSpec.php

示例15: Expr

 function it_adds_empty_filter_in_the_query($attrValidatorHelper, QueryBuilder $queryBuilder, AttributeInterface $number)
 {
     $attrValidatorHelper->validateLocale($number, Argument::any())->shouldBeCalled();
     $attrValidatorHelper->validateScope($number, Argument::any())->shouldBeCalled();
     $number->getId()->willReturn(42);
     $number->getCode()->willReturn('number');
     $number->getBackendType()->willReturn('varchar');
     $number->isLocalizable()->willReturn(false);
     $number->isScopable()->willReturn(false);
     $queryBuilder->expr()->willReturn(new Expr());
     $queryBuilder->getRootAlias()->willReturn('p');
     $queryBuilder->leftJoin('p.values', Argument::any(), 'WITH', Argument::any())->shouldBeCalled();
     $queryBuilder->andWhere(Argument::any())->shouldBeCalled();
     $this->addAttributeFilter($number, 'EMPTY', 12);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:15,代码来源:NumberFilterSpec.php


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