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


PHP QueryBuilder::getAllAliases方法代码示例

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


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

示例1: shouldJoin

 /**
  * Strips the key parts and creates a join if it does not exist yet.
  *
  * @param string $key
  */
 protected function shouldJoin($key)
 {
     $parts = explode('.', $key);
     if (!in_array($parts[0], $this->qb->getAllAliases())) {
         $this->qb->leftJoin($this->getRootAlias() . '.' . $parts[0], $parts[0]);
     }
 }
开发者ID:Opifer,项目名称:Cms,代码行数:12,代码来源:QueryBuilderVisitor.php

示例2: safeLeftJoin

 /**
  * @param QueryBuilder $qb
  * @param string       $attribute
  * @param string       $aliasJoin
  */
 protected function safeLeftJoin(QueryBuilder $qb, string $attribute, string $aliasJoin)
 {
     $aliases = $qb->getAllAliases();
     if (!in_array($aliasJoin, $aliases)) {
         $alias = $this->getAlias($qb);
         $qb->leftJoin($alias . $attribute, $aliasJoin);
     }
 }
开发者ID:Eraac,项目名称:rest-project,代码行数:13,代码来源:AbstractRepository.php

示例3: setQueryParam

 /**
  * @param string $field
  * @param mixed $value
  * @return array
  */
 protected function setQueryParam($field)
 {
     $index = 0;
     $rootAlias = $this->qb->getRootAliases()[$index];
     if (false !== strpos($field, '.')) {
         list($assoc, $subField) = explode('.', $field);
     } else {
         $assoc = $field;
     }
     $meta = $this->getClassMetadata($index);
     if ($meta->hasAssociation($assoc)) {
         $targetClass = $meta->getAssociationTargetClass($assoc);
         if ($meta->isCollectionValuedAssociation($assoc)) {
             $alias = "{$rootAlias}_{$assoc}";
             if (!in_array($alias, $this->qb->getAllAliases())) {
                 $this->qb->leftJoin("{$rootAlias}.{$assoc}", $alias);
             }
             $assoc = $alias;
         } else {
             $alias = "{$rootAlias}_{$assoc}";
             if (!in_array($alias, $this->qb->getAllAliases())) {
                 $this->qb->join("{$rootAlias}.{$assoc}", $alias);
             }
             $assoc = $alias;
         }
         $em = $this->qb->getEntityManager();
         $targetMeta = $em->getClassMetadata($targetClass);
         if (isset($subField) && !$targetMeta->hasField($subField) && $targetMeta->isInheritanceTypeJoined()) {
             foreach ($targetMeta->discriminatorMap as $alias => $class) {
                 $joinedMeta = $em->getClassMetadata($class);
                 if ($joinedMeta->hasField($subField)) {
                     if (!in_array($alias, $this->qb->getAllAliases())) {
                         $this->qb->leftJoin($joinedMeta->getName(), $alias, 'WITH', "{$alias}.id = {$assoc}.id");
                     }
                     $assoc = $alias;
                 }
             }
         }
         $alias = isset($subField) ? "{$assoc}.{$subField}" : $assoc;
     } else {
         $alias = "{$rootAlias}.{$field}";
     }
     $values = array_slice(func_get_args(), 1);
     if ($values) {
         $result = [$alias];
         foreach ($values as $value) {
             $paramName = $this->getParamName($field);
             $this->qb->setParameter($paramName, $value);
             $result[] = ":{$paramName}";
         }
         return $result;
     }
     return $alias;
 }
开发者ID:coolms,项目名称:doctrine-orm,代码行数:59,代码来源:Filter.php

示例4: visitComparison

 /**
  * {@inheritdoc}
  *
  * @throws InvalidArgumentException When a comparison expression is not supported.
  */
 public function visitComparison(Expr\Comparison $comparison)
 {
     $property = $comparison->getProperty();
     $path = explode('.', $property->getPath());
     $expr = $this->builder->expr();
     $aliases = $this->builder->getAllAliases();
     $prefix = reset($aliases);
     foreach (array_slice($path, 0, -1) as $alias) {
         if (!in_array($alias, $aliases)) {
             $this->builder->join(sprintf('%s.%s', $prefix, $alias), $alias);
         }
         $prefix = $alias;
     }
     $field = sprintf('%s.%s', $prefix, end($path));
     $value = $comparison->getValue();
     switch (true) {
         case $comparison instanceof Expr\IdenticalTo:
         case $comparison instanceof Expr\EqualTo:
             return $expr->eq($field, $expr->literal($value));
         case $comparison instanceof Expr\NotIdenticalTo:
         case $comparison instanceof Expr\NotEqualTo:
             return $expr->neq($field, $expr->literal($value));
         case $comparison instanceof Expr\LessThan:
             return $expr->lt($field, $expr->literal($value));
         case $comparison instanceof Expr\LessThanOrEqualTo:
             return $expr->lte($field, $expr->literal($value));
         case $comparison instanceof Expr\GreaterThan:
             return $expr->gt($field, $expr->literal($value));
         case $comparison instanceof Expr\GreaterThanOrEqualTo:
             return $expr->gte($field, $expr->literal($value));
         case $comparison instanceof Expr\In:
             return $expr->in($field, $expr->literal($value));
         case $comparison instanceof Expr\NotIn:
             return $expr->notIn($field, $expr->literal($value));
         case $comparison instanceof Expr\Contains:
             return $expr->like(sprintf('LOWER(%s)', $field), $expr->literal('%' . strtolower($value) . '%'));
     }
     throw new InvalidArgumentException(sprintf('Unsupported comparison operator "%s".', get_class($comparison)));
 }
开发者ID:php-common,项目名称:DoctrineORMSpecificationBridge,代码行数:44,代码来源:QueryBuilderVisitor.php

示例5: getAliases

 /**
  * {@inheritdoc}
  */
 public function getAliases()
 {
     return $this->queryBuilder->getAllAliases();
 }
开发者ID:blazarecki,项目名称:lug,代码行数:7,代码来源:DataSourceBuilder.php

示例6: getJoinColumnAlias

 /**
  * @param QueryBuilder $queryBuilder
  * @param string $name
  * @return string
  */
 public function getJoinColumnAlias(QueryBuilder &$queryBuilder, $name)
 {
     $alias = $queryBuilder->getRootAliases()[0];
     $allAliases = $queryBuilder->getAllAliases();
     $joinParts = explode('.', $name);
     while (count($joinParts) > 1) {
         $joinName = array_shift($joinParts);
         $joinAlias = $alias . '_' . $joinName;
         if (!in_array($joinAlias, $allAliases)) {
             $queryBuilder->leftJoin($alias . '.' . $joinName, $joinAlias);
             $allAliases[] = $joinAlias;
         }
         $alias = $joinAlias;
     }
     return $alias . '.' . current($joinParts);
 }
开发者ID:PoetikDragon,项目名称:USCSS,代码行数:21,代码来源:Datagrid.php


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