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


PHP QueryBuilder::getDQLPart方法代码示例

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


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

示例1: hasOrderByOnToManyJoin

 /**
  * Determines whether the query builder has ORDER BY on entity joined through
  * to-many association.
  *
  * @param QueryBuilder    $queryBuilder
  * @param ManagerRegistry $managerRegistry
  *
  * @return bool
  */
 public static function hasOrderByOnToManyJoin(QueryBuilder $queryBuilder, ManagerRegistry $managerRegistry)
 {
     if (empty($orderByParts = $queryBuilder->getDQLPart('orderBy')) || empty($joinParts = $queryBuilder->getDQLPart('join'))) {
         return false;
     }
     $orderByAliases = [];
     foreach ($orderByParts as $orderBy) {
         $parts = QueryNameGenerator::getOrderByParts($orderBy);
         foreach ($parts as $part) {
             if (false !== ($pos = strpos($part, '.'))) {
                 $alias = substr($part, 0, $pos);
                 $orderByAliases[$alias] = true;
             }
         }
     }
     if (!empty($orderByAliases)) {
         foreach ($joinParts as $rootAlias => $joins) {
             foreach ($joins as $join) {
                 $alias = QueryNameGenerator::getJoinAlias($join);
                 if (isset($orderByAliases[$alias])) {
                     $relationship = QueryNameGenerator::getJoinRelationship($join);
                     $relationshipParts = explode('.', $relationship);
                     $parentAlias = $relationshipParts[0];
                     $association = $relationshipParts[1];
                     $parentMetadata = QueryNameGenerator::getClassMetadataFromJoinAlias($parentAlias, $queryBuilder, $managerRegistry);
                     if ($parentMetadata->isCollectionValuedAssociation($association)) {
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }
开发者ID:akomm,项目名称:DunglasApiBundle,代码行数:43,代码来源:QueryChecker.php

示例2: getQueryResults

 /**
  * Get the query result
  *
  * @param integer $limit
  *
  * @return ArrayCollection
  */
 public function getQueryResults($limit = null)
 {
     if (isset($limit)) {
         $this->queryBuilder->setMaxResults($limit);
     }
     if (!$this->queryBuilder->getDQLPart('orderBy')) {
         $this->queryBuilder->orderBy('a.createdAt', 'ASC');
     }
     return $this->queryBuilder->getQuery()->getResult();
 }
开发者ID:opifer,项目名称:rulesengine,代码行数:17,代码来源:DoctrineEnvironment.php

示例3: testCreateDataSet_conflictingFilters

 public function testCreateDataSet_conflictingFilters()
 {
     $request = $this->getBaseRequest();
     $this->qb->andWhere('p.id = ?0')->setParameter(0, 'Test');
     $request->columnFilters[0] = 'test';
     $dataSet = $this->dataSource->createDataSet($request);
     $where = $this->qb->getDQLPart('where')->getParts();
     $this->assertCount(2, $where);
     $this->assertCount(2, $this->qb->getParameters());
 }
开发者ID:deft,项目名称:datatables-php,代码行数:10,代码来源:QueryBuilderDataSourceTest.php

示例4: hasJoinAlias

 /**
  * {@inheritDoc}
  */
 public function hasJoinAlias($joinAlias)
 {
     $joinParts = $this->queryBuilder->getDQLPart('join');
     /* @var \Doctrine\ORM\Query\Expr\Join $join */
     foreach ($joinParts as $rootAlias => $joins) {
         foreach ($joins as $join) {
             if ($join->getAlias() === $joinAlias) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:11ya,项目名称:LexikFormFilterBundle,代码行数:16,代码来源:ORMQuery.php

示例5: addJoin

 /**
  * @param QueryBuilder $qb
  * @param array $value
  */
 protected function addJoin(QueryBuilder $qb, $value)
 {
     /** @var Expr\From[] $from */
     $from = $qb->getDQLPart('from');
     if ($from) {
         $usedAliases = [$from[0]->getAlias()];
     } else {
         $usedAliases = ['t1'];
     }
     $knownAliases = [$usedAliases[0]];
     if (isset($value['join']['inner'])) {
         foreach ($value['join']['inner'] as $join) {
             $knownAliases[] = $join['alias'];
         }
     }
     if (isset($value['join']['left'])) {
         foreach ($value['join']['left'] as $join) {
             $knownAliases[] = $join['alias'];
         }
     }
     $knownAliases = array_unique($knownAliases);
     $qbTools = new QueryBuilderTools();
     // Add joins ordered by used tables
     $tries = 0;
     do {
         $this->addJoinByDefinition($qb, $qbTools, $value, 'inner', $usedAliases, $knownAliases);
         $this->addJoinByDefinition($qb, $qbTools, $value, 'left', $usedAliases, $knownAliases);
         if ($tries > self::MAX_ITERATIONS) {
             throw new \RuntimeException('Could not reorder joins correctly. Number of tries has exceeded maximum allowed.');
         }
         $tries++;
     } while (count($usedAliases) != count($knownAliases));
 }
开发者ID:northdakota,项目名称:platform,代码行数:37,代码来源:YamlConverter.php

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

示例7: apply

 /**
  * Apply the ACL constraints to the specified query builder, using the permission definition
  *
  * @param QueryBuilder         $queryBuilder  The query builder
  * @param PermissionDefinition $permissionDef The permission definition
  *
  * @return Query
  */
 public function apply(QueryBuilder $queryBuilder, PermissionDefinition $permissionDef)
 {
     $whereQueryParts = $queryBuilder->getDQLPart('where');
     if (empty($whereQueryParts)) {
         $queryBuilder->where('1 = 1');
         // this will help in cases where no where query is specified
     }
     $query = $this->cloneQuery($queryBuilder->getQuery());
     $builder = new MaskBuilder();
     foreach ($permissionDef->getPermissions() as $permission) {
         $mask = constant(get_class($builder) . '::MASK_' . strtoupper($permission));
         $builder->add($mask);
     }
     $query->setHint('acl.mask', $builder->get());
     $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Kunstmaan\\AdminBundle\\Helper\\Security\\Acl\\AclWalker');
     $rootEntity = $permissionDef->getEntity();
     $rootAlias = $permissionDef->getAlias();
     // If either alias or entity was not specified - use default from QueryBuilder
     if (empty($rootEntity) || empty($rootAlias)) {
         $rootEntities = $queryBuilder->getRootEntities();
         $rootAliases = $queryBuilder->getRootAliases();
         $rootEntity = $rootEntities[0];
         $rootAlias = $rootAliases[0];
     }
     $query->setHint('acl.root.entity', $rootEntity);
     $query->setHint('acl.extra.query', $this->getPermittedAclIdsSQLForUser($query));
     $classMeta = $this->em->getClassMetadata($rootEntity);
     $entityRootTableName = $this->quoteStrategy->getTableName($classMeta, $this->em->getConnection()->getDatabasePlatform());
     $query->setHint('acl.entityRootTableName', $entityRootTableName);
     $query->setHint('acl.entityRootTableDqlAlias', $rootAlias);
     return $query;
 }
开发者ID:axelvnk,项目名称:KunstmaanBundlesCMS,代码行数:40,代码来源:AclHelper.php

示例8: getRootTableAlias

 /**
  * @param QueryBuilder $qb
  * @return string
  */
 protected function getRootTableAlias(QueryBuilder $qb)
 {
     $fromParts = $qb->getDQLPart('from');
     /** @var From $from */
     $from = reset($fromParts);
     return $from->getAlias();
 }
开发者ID:aculvi,项目名称:OroCRMMailChimpBundle,代码行数:11,代码来源:FieldHelper.php

示例9: getDistinct

 /**
  * Returns the sql expression to determinate the distincts numbers of lines
  *
  * @return string
  */
 protected function getDistinct()
 {
     if (isset($this->conf->group)) {
         return $this->conf->group;
     }
     return implode(', ', $this->queryBuilder->getDQLPart('select'));
 }
开发者ID:solire,项目名称:trieur,代码行数:12,代码来源:DoctrineOrm.php

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

示例11: getRootIds

 /**
  * Get root entities config data
  *
  * @param QueryBuilder $query
  * @return array with root entities config
  */
 protected function getRootIds(QueryBuilder $query)
 {
     $groupParts = $this->getGroupParts();
     $rootIds = [];
     if (empty($groupParts)) {
         $rootIdentifiers = $query->getEntityManager()->getClassMetadata($query->getRootEntities()[0])->getIdentifier();
         $rootAlias = $query->getRootAliases()[0];
         foreach ($rootIdentifiers as $field) {
             $rootIds[] = ['fieldAlias' => $field, 'alias' => $field, 'entityAlias' => $rootAlias];
         }
     } else {
         foreach ($groupParts as $groupPart) {
             if (strpos($groupPart, '.')) {
                 list($rootAlias, $rootIdentifierPart) = explode('.', $groupPart);
                 $rootIds[] = ['fieldAlias' => $rootIdentifierPart, 'entityAlias' => $rootAlias, 'alias' => $rootIdentifierPart];
             } else {
                 $selectParts = $this->masterQB->getDQLPart('select');
                 /** @var Select $selectPart */
                 foreach ($selectParts as $selectPart) {
                     foreach ($selectPart->getParts() as $part) {
                         if (preg_match('/^(.*)\\sas\\s(.*)$/i', $part, $matches)) {
                             if (count($matches) == 3 && $groupPart == $matches[2]) {
                                 $rootIds[] = ['fieldAlias' => $matches[1], 'alias' => $matches[2]];
                             }
                         } else {
                             $rootIds[] = ['fieldAlias' => $groupPart, 'alias' => $groupPart];
                         }
                     }
                 }
             }
         }
     }
     return $rootIds;
 }
开发者ID:gmoigneu,项目名称:platform,代码行数:40,代码来源:OrmTotalsExtension.php

示例12: getAlias

 private function getAlias(QueryBuilder $builder)
 {
     $dql_part = $builder->getDQLPart('from');
     if (!is_array($dql_part) || count($dql_part) !== 1 || !$dql_part[0] instanceof \Doctrine\ORM\Query\Expr\From) {
         throw new \DomainException('The from should be an instance of from');
     }
     return $dql_part[0]->getAlias();
 }
开发者ID:eddypouw,项目名称:hnDependencyInjectionPlugin,代码行数:8,代码来源:DoctrinePager.php

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

示例14: initIdFieldName

 /**
  * Initialize the column id of the targeted class.
  *
  * @return string
  */
 protected function initIdFieldName()
 {
     /** @var $from \Doctrine\ORM\Query\Expr\From */
     $from = current($this->originalQb->getDQLPart('from'));
     $class = $from->getFrom();
     $idNames = $this->originalQb->getEntityManager()->getMetadataFactory()->getMetadataFor($class)->getIdentifierFieldNames();
     $this->idFieldName = current($idNames);
 }
开发者ID:northdakota,项目名称:platform,代码行数:13,代码来源:CountQueryBuilderOptimizer.php

示例15: getWhereParts

 /**
  *
  * @param  QueryBuilder                          $qb
  * @param  number                                $part
  * @return \Doctrine\ORM\Query\Expr\Comparison[]
  */
 private function getWhereParts(QueryBuilder $qb, $part = 0)
 {
     /* @var $where \Doctrine\ORM\Query\Expr\Andx */
     $where = $qb->getDQLPart('where');
     $whereParts = $where->getParts();
     $this->assertInstanceOf('Doctrine\\ORM\\Query\\Expr\\Orx', $whereParts[$part]);
     return $whereParts[$part]->getParts();
 }
开发者ID:DAICAR,项目名称:ZfcDatagrid,代码行数:14,代码来源:FilterTest.php


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