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


PHP QueryException::invalidPathExpression方法代码示例

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


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

示例1: walkSelectExpression

 /**
  * Walks down a SelectExpression AST node and generates the corresponding SQL.
  *
  * @param SelectExpression $selectExpression
  * @return string The SQL.
  */
 public function walkSelectExpression($selectExpression)
 {
     $sql = '';
     $expr = $selectExpression->expression;
     if ($expr instanceof AST\PathExpression) {
         if ($expr->type == AST\PathExpression::TYPE_STATE_FIELD) {
             $parts = $expr->parts;
             $fieldName = array_pop($parts);
             $dqlAlias = $expr->identificationVariable . (!empty($parts) ? '.' . implode('.', $parts) : '');
             $qComp = $this->_queryComponents[$dqlAlias];
             $class = $qComp['metadata'];
             if (!$selectExpression->fieldIdentificationVariable) {
                 $resultAlias = $fieldName;
             } else {
                 $resultAlias = $selectExpression->fieldIdentificationVariable;
             }
             if ($class->isInheritanceTypeJoined()) {
                 $tableName = $this->_em->getUnitOfWork()->getEntityPersister($class->name)->getOwningTable($fieldName);
             } else {
                 $tableName = $class->getTableName();
             }
             $sqlTableAlias = $this->getSqlTableAlias($tableName, $dqlAlias);
             $columnName = $class->getQuotedColumnName($fieldName, $this->_platform);
             $columnAlias = $this->getSqlColumnAlias($columnName);
             $sql .= $sqlTableAlias . '.' . $columnName . ' AS ' . $columnAlias;
             $columnAlias = $this->_platform->getSQLResultCasing($columnAlias);
             $this->_rsm->addScalarResult($columnAlias, $resultAlias);
         } else {
             throw QueryException::invalidPathExpression($expr->type);
         }
     } else {
         if ($expr instanceof AST\AggregateExpression) {
             if (!$selectExpression->fieldIdentificationVariable) {
                 $resultAlias = $this->_scalarResultCounter++;
             } else {
                 $resultAlias = $selectExpression->fieldIdentificationVariable;
             }
             $columnAlias = 'sclr' . $this->_aliasCounter++;
             $sql .= $this->walkAggregateExpression($expr) . ' AS ' . $columnAlias;
             $this->_scalarResultAliasMap[$resultAlias] = $columnAlias;
             $columnAlias = $this->_platform->getSQLResultCasing($columnAlias);
             $this->_rsm->addScalarResult($columnAlias, $resultAlias);
         } else {
             if ($expr instanceof AST\Subselect) {
                 if (!$selectExpression->fieldIdentificationVariable) {
                     $resultAlias = $this->_scalarResultCounter++;
                 } else {
                     $resultAlias = $selectExpression->fieldIdentificationVariable;
                 }
                 $columnAlias = 'sclr' . $this->_aliasCounter++;
                 $sql .= '(' . $this->walkSubselect($expr) . ') AS ' . $columnAlias;
                 $this->_scalarResultAliasMap[$resultAlias] = $columnAlias;
                 $columnAlias = $this->_platform->getSQLResultCasing($columnAlias);
                 $this->_rsm->addScalarResult($columnAlias, $resultAlias);
             } else {
                 if ($expr instanceof AST\Functions\FunctionNode) {
                     if (!$selectExpression->fieldIdentificationVariable) {
                         $resultAlias = $this->_scalarResultCounter++;
                     } else {
                         $resultAlias = $selectExpression->fieldIdentificationVariable;
                     }
                     $columnAlias = 'sclr' . $this->_aliasCounter++;
                     $sql .= $this->walkFunction($expr) . ' AS ' . $columnAlias;
                     $this->_scalarResultAliasMap[$resultAlias] = $columnAlias;
                     $columnAlias = $this->_platform->getSQLResultCasing($columnAlias);
                     $this->_rsm->addScalarResult($columnAlias, $resultAlias);
                 } else {
                     if ($expr instanceof AST\SimpleArithmeticExpression) {
                         if (!$selectExpression->fieldIdentificationVariable) {
                             $resultAlias = $this->_scalarResultCounter++;
                         } else {
                             $resultAlias = $selectExpression->fieldIdentificationVariable;
                         }
                         $columnAlias = 'sclr' . $this->_aliasCounter++;
                         $sql .= $this->walkSimpleArithmeticExpression($expr) . ' AS ' . $columnAlias;
                         $this->_scalarResultAliasMap[$resultAlias] = $columnAlias;
                         $columnAlias = $this->_platform->getSQLResultCasing($columnAlias);
                         $this->_rsm->addScalarResult($columnAlias, $resultAlias);
                     } else {
                         // IdentificationVariable or PartialObjectExpression
                         if ($expr instanceof AST\PartialObjectExpression) {
                             $dqlAlias = $expr->identificationVariable;
                             $partialFieldSet = $expr->partialFieldSet;
                         } else {
                             $dqlAlias = $expr;
                             $partialFieldSet = array();
                         }
                         $queryComp = $this->_queryComponents[$dqlAlias];
                         $class = $queryComp['metadata'];
                         if (!isset($this->_selectedClasses[$dqlAlias])) {
                             $this->_selectedClasses[$dqlAlias] = $class;
                         }
                         $beginning = true;
                         // Select all fields from the queried class
//.........这里部分代码省略.........
开发者ID:andreia,项目名称:doctrine,代码行数:101,代码来源:SqlWalker.php

示例2: walkSelectExpression

 /**
  * {@inheritdoc}
  */
 public function walkSelectExpression($selectExpression)
 {
     $sql = '';
     $expr = $selectExpression->expression;
     $hidden = $selectExpression->hiddenAliasResultVariable;
     switch (true) {
         case $expr instanceof AST\PathExpression:
             if ($expr->type !== AST\PathExpression::TYPE_STATE_FIELD) {
                 throw QueryException::invalidPathExpression($expr);
             }
             $fieldName = $expr->field;
             $dqlAlias = $expr->identificationVariable;
             $qComp = $this->queryComponents[$dqlAlias];
             $class = $qComp['metadata'];
             $resultAlias = $selectExpression->fieldIdentificationVariable ?: $fieldName;
             $tableName = $class->isInheritanceTypeJoined() ? $this->em->getUnitOfWork()->getEntityPersister($class->name)->getOwningTable($fieldName) : $class->getTableName();
             $sqlTableAlias = $this->getSQLTableAlias($tableName, $dqlAlias);
             $columnName = $this->quoteStrategy->getColumnName($fieldName, $class, $this->platform);
             $columnAlias = $this->getSQLColumnAlias($class->fieldMappings[$fieldName]['columnName']);
             $col = $sqlTableAlias . '.' . $columnName;
             $fieldType = $class->getTypeOfField($fieldName);
             if (isset($class->fieldMappings[$fieldName]['requireSQLConversion'])) {
                 $type = Type::getType($fieldType);
                 $col = $type->convertToPHPValueSQL($col, $this->conn->getDatabasePlatform());
             }
             $sql .= $col . ' AS ' . $columnAlias;
             $this->scalarResultAliasMap[$resultAlias] = $columnAlias;
             if (!$hidden) {
                 $this->rsm->addScalarResult($columnAlias, $resultAlias, $fieldType);
                 $this->scalarFields[$dqlAlias][$fieldName] = $columnAlias;
             }
             break;
         case $expr instanceof AST\AggregateExpression:
         case $expr instanceof AST\Functions\FunctionNode:
         case $expr instanceof AST\SimpleArithmeticExpression:
         case $expr instanceof AST\ArithmeticTerm:
         case $expr instanceof AST\ArithmeticFactor:
         case $expr instanceof AST\Literal:
         case $expr instanceof AST\NullIfExpression:
         case $expr instanceof AST\CoalesceExpression:
         case $expr instanceof AST\GeneralCaseExpression:
         case $expr instanceof AST\SimpleCaseExpression:
             $columnAlias = $this->getSQLColumnAlias('sclr');
             $resultAlias = $selectExpression->fieldIdentificationVariable ?: $this->scalarResultCounter++;
             $sql .= $expr->dispatch($this) . ' AS ' . $columnAlias;
             $this->scalarResultAliasMap[$resultAlias] = $columnAlias;
             if (!$hidden) {
                 // We cannot resolve field type here; assume 'string'.
                 $this->rsm->addScalarResult($columnAlias, $resultAlias, 'string');
             }
             break;
         case $expr instanceof AST\Subselect:
             $columnAlias = $this->getSQLColumnAlias('sclr');
             $resultAlias = $selectExpression->fieldIdentificationVariable ?: $this->scalarResultCounter++;
             $sql .= '(' . $this->walkSubselect($expr) . ') AS ' . $columnAlias;
             $this->scalarResultAliasMap[$resultAlias] = $columnAlias;
             if (!$hidden) {
                 // We cannot resolve field type here; assume 'string'.
                 $this->rsm->addScalarResult($columnAlias, $resultAlias, 'string');
             }
             break;
         case $expr instanceof AST\NewObjectExpression:
             $sql .= $this->walkNewObject($expr);
             break;
         default:
             // IdentificationVariable or PartialObjectExpression
             if ($expr instanceof AST\PartialObjectExpression) {
                 $dqlAlias = $expr->identificationVariable;
                 $partialFieldSet = $expr->partialFieldSet;
             } else {
                 $dqlAlias = $expr;
                 $partialFieldSet = array();
             }
             $queryComp = $this->queryComponents[$dqlAlias];
             $class = $queryComp['metadata'];
             $resultAlias = $selectExpression->fieldIdentificationVariable ?: null;
             if (!isset($this->selectedClasses[$dqlAlias])) {
                 $this->selectedClasses[$dqlAlias] = array('class' => $class, 'dqlAlias' => $dqlAlias, 'resultAlias' => $resultAlias);
             }
             $sqlParts = array();
             // Select all fields from the queried class
             foreach ($class->fieldMappings as $fieldName => $mapping) {
                 if ($partialFieldSet && !in_array($fieldName, $partialFieldSet)) {
                     continue;
                 }
                 $tableName = isset($mapping['inherited']) ? $this->em->getClassMetadata($mapping['inherited'])->getTableName() : $class->getTableName();
                 $sqlTableAlias = $this->getSQLTableAlias($tableName, $dqlAlias);
                 $columnAlias = $this->getSQLColumnAlias($mapping['columnName']);
                 $quotedColumnName = $this->quoteStrategy->getColumnName($fieldName, $class, $this->platform);
                 $col = $sqlTableAlias . '.' . $quotedColumnName;
                 if (isset($class->fieldMappings[$fieldName]['requireSQLConversion'])) {
                     $type = Type::getType($class->getTypeOfField($fieldName));
                     $col = $type->convertToPHPValueSQL($col, $this->platform);
                 }
                 $sqlParts[] = $col . ' AS ' . $columnAlias;
                 $this->scalarResultAliasMap[$resultAlias][] = $columnAlias;
                 $this->rsm->addFieldResult($dqlAlias, $columnAlias, $fieldName, $class->name);
//.........这里部分代码省略.........
开发者ID:nemekzg,项目名称:doctrine2,代码行数:101,代码来源:SqlWalker.php

示例3: walkPathExpression

 /**
  * Walks down a PathExpression AST node, thereby generating the appropriate SQL.
  *
  * @param mixed
  * @return string The SQL.
  */
 public function walkPathExpression($pathExpr)
 {
     $sql = '';
     $pathExprType = $pathExpr->type;
     switch ($pathExpr->type) {
         case AST\PathExpression::TYPE_STATE_FIELD:
             $parts = $pathExpr->parts;
             $fieldName = array_pop($parts);
             $dqlAlias = $pathExpr->identificationVariable . (!empty($parts) ? '.' . implode('.', $parts) : '');
             $qComp = $this->_queryComponents[$dqlAlias];
             $class = $qComp['metadata'];
             if ($this->_useSqlTableAliases) {
                 $sql .= $this->walkIdentificationVariable($dqlAlias, $fieldName) . '.';
             }
             $sql .= $class->getQuotedColumnName($fieldName, $this->_platform);
             break;
         case AST\PathExpression::TYPE_SINGLE_VALUED_ASSOCIATION:
             // "u.Group" should be converted to:
             // 1- IdentificationVariable is the owning side:
             //    Just append the condition: u.group_id = ?
             /*$parts = $pathExpr->parts;
               $numParts = count($parts);
               $dqlAlias = $pathExpr->identificationVariable;
               $fieldName = $parts[$numParts - 1];
               $qComp = $this->_queryComponents[$dqlAlias];
               $class = $qComp['metadata'];
               $assoc = $class->associationMappings[$fieldName];
               
               if ($assoc->isOwningSide) {
                   foreach ($assoc->)
                   $sql .= $this->walkIdentificationVariable($dqlAlias, $fieldName) . '.';
                   
               }
               
               // 2- IdentificationVariable is the inverse side:
               //    Join required: INNER JOIN u.Group g
               //    Append condition: g.id = ?
               break;*/
         // "u.Group" should be converted to:
         // 1- IdentificationVariable is the owning side:
         //    Just append the condition: u.group_id = ?
         /*$parts = $pathExpr->parts;
           $numParts = count($parts);
           $dqlAlias = $pathExpr->identificationVariable;
           $fieldName = $parts[$numParts - 1];
           $qComp = $this->_queryComponents[$dqlAlias];
           $class = $qComp['metadata'];
           $assoc = $class->associationMappings[$fieldName];
           
           if ($assoc->isOwningSide) {
               foreach ($assoc->)
               $sql .= $this->walkIdentificationVariable($dqlAlias, $fieldName) . '.';
               
           }
           
           // 2- IdentificationVariable is the inverse side:
           //    Join required: INNER JOIN u.Group g
           //    Append condition: g.id = ?
           break;*/
         case AST\PathExpression::TYPE_COLLECTION_VALUED_ASSOCIATION:
             throw DoctrineException::notImplemented();
         default:
             throw QueryException::invalidPathExpression($pathExpr);
     }
     return $sql;
 }
开发者ID:nvdnkpr,项目名称:symfony-demo,代码行数:72,代码来源:SqlWalker.php


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