當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。