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


PHP QueryBuilder::getRootAliases方法代码示例

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


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

示例1: checkAliases

 private function checkAliases($column)
 {
     if (Strings::contains($column, ".")) {
         return $column;
     }
     return current($this->data_source->getRootAliases()) . '.' . $column;
 }
开发者ID:OCC2,项目名称:occ2pacs,代码行数:7,代码来源:DoctrineDataSource.php

示例2: createPropertyPathMapping

 public function createPropertyPathMapping(QueryBuilder $qb, array $fieldMapping, array $existingMapping = [])
 {
     if (count($qb->getRootAliases()) > 1) {
         throw new \UnexpectedValueException("Expected 1 root alias");
     }
     $rootAlias = $qb->getRootAliases()[0];
     $aliasMapping = [$rootAlias => ''];
     foreach ($qb->getDQLPart('join') as $joinFrom => $joins) {
         foreach ($joins as $join) {
             $joinParts = explode(".", $join->getJoin());
             $aliasMapping[$join->getAlias()] = trim($aliasMapping[$joinParts[0]] . '.' . $joinParts[1], '.');
         }
     }
     $mapping = [];
     foreach ($fieldMapping as $key => $field) {
         if (array_key_exists($key, $existingMapping)) {
             $mapping[$key] = $existingMapping[$key];
             continue;
         }
         $fieldParts = explode('.', $field);
         if (isset($fieldParts[1])) {
             $alias = $fieldParts[0];
             $mapping[$key] = trim($aliasMapping[$fieldParts[0]] . '.' . $fieldParts[1], '.');
         } else {
             $mapping[$key] = trim($fieldParts[0]);
         }
     }
     return $mapping;
 }
开发者ID:deft,项目名称:datatables-php,代码行数:29,代码来源:PropertyPathMappingFactory.php

示例3: addFieldFilter

 /**
  * {@inheritdoc}
  */
 public function addFieldFilter($field, $operator, $value)
 {
     $field = current($this->qb->getRootAliases()) . '.' . $field;
     $condition = $this->prepareCriteriaCondition($field, $operator, $value);
     $this->qb->andWhere($condition);
     return $this;
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:10,代码来源:BaseFilter.php

示例4: addFieldSorter

 /**
  * {@inheritdoc}
  */
 public function addFieldSorter($field, $direction, $locale = null, $scope = null)
 {
     $field = current($this->qb->getRootAliases()) . '.' . $field;
     $this->qb->addOrderBy($field, $direction);
     $idField = $this->qb->getRootAlias() . '.id';
     $this->qb->addOrderBy($idField);
     return $this;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:11,代码来源:BaseSorter.php

示例5: setOriginalQueryBuilder

 /**
  * Set original query builder.
  *
  * @param QueryBuilder $originalQb
  */
 protected function setOriginalQueryBuilder(QueryBuilder $originalQb)
 {
     $this->originalQb = $originalQb;
     $this->qbTools->prepareFieldAliases($originalQb->getDQLPart('select'));
     $this->qbTools->prepareJoinTablePaths($originalQb->getDQLPart('join'));
     $this->rootAlias = current($this->originalQb->getRootAliases());
     $this->initIdFieldName();
 }
开发者ID:northdakota,项目名称:platform,代码行数:13,代码来源:CountQueryBuilderOptimizer.php

示例6: getCount

 public function getCount()
 {
     if ($this->count === NULL) {
         $alias = $this->builder->getRootAliases();
         $builder = clone $this->builder;
         $result = $builder->select('COUNT(' . current($alias) . '.id) AS count')->getQuery()->getSingleResult();
         $this->count = $result['count'];
     }
     return $this->count;
 }
开发者ID:WebChemistry,项目名称:filter,代码行数:10,代码来源:Doctrine.php

示例7: checkAliases

 /**
  * @param  string  $column
  * @return string
  */
 private function checkAliases($column)
 {
     if (Strings::contains($column, ".")) {
         return $column;
     }
     if (!isset($this->root_alias)) {
         $this->root_alias = $this->data_source->getRootAliases();
         $this->root_alias = current($this->root_alias);
     }
     return $this->root_alias . '.' . $column;
 }
开发者ID:romanmatyus,项目名称:datagrid,代码行数:15,代码来源:DoctrineDataSource.php

示例8: addFilterByOrderStatus

 /**
  * @param QueryBuilder $qb
  * @param string       $orderStatus
  */
 protected function addFilterByOrderStatus(QueryBuilder $qb, $orderStatus)
 {
     $aliases = $qb->getRootAliases();
     $subQueryBuilder = $this->customerRepository->createQueryBuilder('c');
     $subQueryBuilder->select('IDENTITY(c.account)')->join('c.orders', 'o', 'WITH', $subQueryBuilder->expr()->eq($subQueryBuilder->expr()->lower('o.status'), ':filteredOrderStatus'));
     $qb->andWhere($qb->expr()->in($aliases[0] . '.account', $subQueryBuilder->getDQL()))->setParameter('filteredOrderStatus', $orderStatus);
 }
开发者ID:antrampa,项目名称:crm,代码行数:11,代码来源:UpdateCustomerLifetimeForCanceledOrders.php

示例9: autoJoin

 private function autoJoin(QueryBuilder $queryBuilder)
 {
     foreach ($this->expectedJoinChains as $tablesToJoin) {
         // check if the first dimension is a known alias
         if (isset($this->knownAliases[$tablesToJoin[0]])) {
             $joinTo = $tablesToJoin[0];
             array_pop($tablesToJoin);
         } else {
             // if not, it's the root table
             $joinTo = $queryBuilder->getRootAliases()[0];
         }
         foreach ($tablesToJoin as $table) {
             $joinAlias = self::ALIAS_PREFIX . $table;
             $join = sprintf('%s.%s', $joinTo, $table);
             if (!isset($this->joinMap[$join])) {
                 $this->joinMap[$join] = $joinAlias;
                 $this->knownAliases[$joinAlias] = true;
                 $queryBuilder->join(sprintf('%s.%s', $joinTo, $table), $joinAlias);
             } else {
                 $joinAlias = $this->joinMap[$join];
             }
             $joinTo = $joinAlias;
         }
     }
 }
开发者ID:j0k3r,项目名称:rulerz,代码行数:25,代码来源:AutoJoin.php

示例10: paginateQuery

 /**
  * @param QueryBuilder $query
  * @param int $per_page
  * @param int $current_page
  *
  * @return Configuration
  */
 public function paginateQuery(QueryBuilder $query, $per_page, $current_page = 1)
 {
     $counter = clone $query;
     $total = $counter->select(sprintf('COUNT(%s)', current($query->getRootAliases())))->getQuery()->getSingleScalarResult();
     $query->setFirstResult(($current_page - 1) * $per_page)->setMaxResults($per_page);
     return (new Configuration(ceil($total / $per_page), $current_page))->setMaxNavigate($this->max_navigate);
 }
开发者ID:anime-db,项目名称:pagination-bundle,代码行数:14,代码来源:Builder.php

示例11: Expr

 function it_adds_binary_filter_in_the_query(QueryBuilder $queryBuilder)
 {
     $queryBuilder->expr()->willReturn(new Expr());
     $queryBuilder->getRootAliases()->willReturn(['p']);
     $queryBuilder->andWhere('p.id = \'12\'')->shouldBeCalled();
     $this->addFieldFilter('id', '=', '12');
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:7,代码来源:ProductIdFilterSpec.php

示例12: sort

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

示例13: getItems

 /**
  * @return mixed
  */
 public function getItems()
 {
     $this->qb->setMaxResults($this->getLimit());
     $this->qb->setFirstResult($this->getOffset());
     if (count($this->getSorting()) > 0) {
         foreach ($this->getSorting() as $sortColumn => $sortType) {
             if (isset($this->columnAliases[$sortColumn])) {
                 $sortColumn = $this->columnAliases[$sortColumn]->qbName;
             } else {
                 $aliases = $this->qb->getRootAliases();
                 $sortColumn = $aliases[0] . '.' . $sortColumn;
             }
             $this->qb->addOrderBy($sortColumn, is_string($sortType) && strncasecmp($sortType, 'd', 1) || $sortType > 0 ? 'ASC' : 'DESC');
         }
     }
     return $this->qb->getQuery()->getResult();
 }
开发者ID:natrim,项目名称:gridito,代码行数:20,代码来源:DoctrineQueryBuilderModel.php

示例14: filter

 /**
  * {@inheritdoc}
  */
 public function filter(Request $request, QueryBuilder $queryBuilder)
 {
     $order = $request->query->get('order') ?: self::DEFAULT_ORDER;
     if ($request->query->has('sort')) {
         $alias = $queryBuilder->getRootAliases()[0];
         $queryBuilder->orderBy($alias . '.' . $request->query->get('sort'), $order);
     }
 }
开发者ID:csbill,项目名称:csbill,代码行数:11,代码来源:SortFilter.php

示例15: setSourceQueryBuilder

 /**
  * {@inheritdoc}
  */
 public function setSourceQueryBuilder(QueryBuilder $queryBuilder)
 {
     if ($this->priceListId) {
         $aliases = $queryBuilder->getRootAliases();
         $rootAlias = reset($aliases);
         $queryBuilder->andWhere($queryBuilder->expr()->eq(sprintf('IDENTITY(%s.priceList)', $rootAlias), ':priceList'))->setParameter('priceList', $this->priceListId);
     }
     parent::setSourceQueryBuilder($queryBuilder);
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:12,代码来源:PriceListProductPricesReader.php


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