當前位置: 首頁>>代碼示例>>PHP>>正文


PHP QueryBuilder::getDqlPart方法代碼示例

本文整理匯總了PHP中Doctrine\ORM\QueryBuilder::getDqlPart方法的典型用法代碼示例。如果您正苦於以下問題:PHP QueryBuilder::getDqlPart方法的具體用法?PHP QueryBuilder::getDqlPart怎麽用?PHP QueryBuilder::getDqlPart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ORM\QueryBuilder的用法示例。


在下文中一共展示了QueryBuilder::getDqlPart方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testCreateDataSet_sort

 public function testCreateDataSet_sort()
 {
     $request = $this->getBaseRequest();
     $request->columnSorts = [0 => 'desc', 1 => 'asc'];
     $dataSet = $this->dataSource->createDataSet($request);
     $orderBy = $this->qb->getDqlPart('orderBy');
     $this->assertEquals('p.name desc', $orderBy[0]->__toString());
     $this->assertEquals('p.price asc', $orderBy[1]->__toString());
 }
開發者ID:deft,項目名稱:datatables-php,代碼行數:9,代碼來源:QueryBuilderDataSourceTest.php

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

示例3: retrieveExpressionByFieldName

 private function retrieveExpressionByFieldName($fieldName)
 {
     /** @var $selectPart \Doctrine\ORM\Query\Expr\Select */
     foreach ($this->qb->getDqlPart('select') as $selectPart) {
         foreach ($selectPart->getParts() as $part) {
             $pattern = "/^(.+) AS (?:|HIDDEN ){$fieldName}\$/i";
             if (preg_match($pattern, $part, $matches)) {
                 return $matches[1];
             }
         }
     }
     throw new \InvalidArgumentException("Expression for field '{$fieldName}' could not be determined.");
 }
開發者ID:deft,項目名稱:datatables-php,代碼行數:13,代碼來源:QueryBuilderDataSource.php

示例4: getItemsCountInCategory

 /**
  * {@inherit}
  */
 public function getItemsCountInCategory(CategoryInterface $category, QueryBuilder $categoryQb = null)
 {
     $qb = $this->em->createQueryBuilder();
     $qb->select($qb->expr()->count('distinct i'));
     $qb->from($this->entityName, 'i');
     $qb->join('i.categories', 'node');
     if (null === $categoryQb) {
         $qb->where('node.id = :nodeId');
         $qb->setParameter('nodeId', $category->getId());
     } else {
         $qb->where($categoryQb->getDqlPart('where'));
         $qb->setParameters($categoryQb->getParameters());
     }
     return $qb->getQuery()->getSingleScalarResult();
 }
開發者ID:alexisfroger,項目名稱:pim-community-dev,代碼行數:18,代碼來源:AbstractItemCategoryRepository.php

示例5: checkIfQueryHasFetchJoin

 /**
  * @param QueryBuilder $qb
  * @return boolean
  */
 protected function checkIfQueryHasFetchJoin(QueryBuilder $qb)
 {
     $join = $qb->getDqlPart('join');
     if (empty($join)) {
         return false;
     }
     foreach ($join[$this->getTableAlias()] as $join) {
         if ($join->getJoinType() === Join::INNER_JOIN || $join->getJoinType() === Join::LEFT_JOIN) {
             return true;
         }
     }
     return false;
 }
開發者ID:Opifer,項目名稱:Cms,代碼行數:17,代碼來源:Entity.php

示例6: getProductIdsInCategory

 /**
  * {@inheritdoc}
  */
 public function getProductIdsInCategory(CategoryInterface $category, QueryBuilder $categoryQb = null)
 {
     $qb = $this->em->createQueryBuilder();
     $qb->select('p.id');
     $qb->from($this->entityName, 'p');
     $qb->join('p.categories', 'node');
     if (null === $categoryQb) {
         $qb->where('node.id = :nodeId');
         $qb->setParameter('nodeId', $category->getId());
     } else {
         $qb->where($categoryQb->getDqlPart('where'));
         $qb->setParameters($categoryQb->getParameters());
     }
     $products = $qb->getQuery()->execute(array(), AbstractQuery::HYDRATE_ARRAY);
     $productIds = array();
     foreach ($products as $product) {
         $productIds[] = $product['id'];
     }
     $productIds = array_unique($productIds);
     return $productIds;
 }
開發者ID:javiersantos,項目名稱:pim-community-dev,代碼行數:24,代碼來源:ProductCategoryRepository.php


注:本文中的Doctrine\ORM\QueryBuilder::getDqlPart方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。