当前位置: 首页>>代码示例>>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;未经允许,请勿转载。