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


PHP QueryException::instanceOfUnrelatedClass方法代碼示例

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


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

示例1: walkInstanceOfExpression

 /**
  * Walks down an InstanceOfExpression AST node, thereby generating the appropriate SQL.
  *
  * @param InstanceOfExpression
  * @return string The SQL.
  */
 public function walkInstanceOfExpression($instanceOfExpr)
 {
     $sql = '';
     $dqlAlias = $instanceOfExpr->identificationVariable;
     $discrClass = $class = $this->queryComponents[$dqlAlias]['metadata'];
     if ($class->discriminatorColumn) {
         $discrClass = $this->em->getClassMetadata($class->rootEntityName);
     }
     if ($this->useSqlTableAliases) {
         $sql .= $this->getSQLTableAlias($discrClass->getTableName(), $dqlAlias) . '.';
     }
     $sql .= $class->discriminatorColumn['name'] . ($instanceOfExpr->not ? ' NOT IN ' : ' IN ');
     $sqlParameterList = array();
     foreach ($instanceOfExpr->value as $parameter) {
         if ($parameter instanceof AST\InputParameter) {
             $sqlParameterList[] = $this->walkInputParameter($parameter);
         } else {
             // Get name from ClassMetadata to resolve aliases.
             $entityClassName = $this->em->getClassMetadata($parameter)->name;
             if ($entityClassName == $class->name) {
                 $sqlParameterList[] = $this->conn->quote($class->discriminatorValue);
             } else {
                 $discrMap = array_flip($class->discriminatorMap);
                 if (!isset($discrMap[$entityClassName])) {
                     throw QueryException::instanceOfUnrelatedClass($entityClassName, $class->rootEntityName);
                 }
                 $sqlParameterList[] = $this->conn->quote($discrMap[$entityClassName]);
             }
         }
     }
     $sql .= '(' . implode(', ', $sqlParameterList) . ')';
     return $sql;
 }
開發者ID:bardascat,項目名稱:blogify,代碼行數:39,代碼來源:SqlWalker.php

示例2: walkInstanceOfExpression

 /**
  * {@inheritdoc}
  */
 public function walkInstanceOfExpression($instanceOfExpr)
 {
     $sql = '';
     $dqlAlias = $instanceOfExpr->identificationVariable;
     $discrClass = $class = $this->queryComponents[$dqlAlias]['metadata'];
     if ($class->discriminatorColumn) {
         $discrClass = $this->em->getClassMetadata($class->rootEntityName);
     }
     if ($this->useSqlTableAliases) {
         $sql .= $this->getSQLTableAlias($discrClass->getTableName(), $dqlAlias) . '.';
     }
     $sql .= $class->discriminatorColumn['name'] . ($instanceOfExpr->not ? ' NOT IN ' : ' IN ');
     $sqlParameterList = array();
     foreach ($instanceOfExpr->value as $parameter) {
         if ($parameter instanceof AST\InputParameter) {
             // We need to modify the parameter value to be its correspondent mapped value
             $dqlParamKey = $parameter->name;
             $dqlParam = $this->query->getParameter($dqlParamKey);
             $paramValue = $this->query->processParameterValue($dqlParam->getValue());
             if (!$paramValue instanceof \Doctrine\ORM\Mapping\ClassMetadata) {
                 throw QueryException::invalidParameterType('ClassMetadata', get_class($paramValue));
             }
             $entityClassName = $paramValue->name;
         } else {
             // Get name from ClassMetadata to resolve aliases.
             $entityClassName = $this->em->getClassMetadata($parameter)->name;
         }
         if ($entityClassName == $class->name) {
             $sqlParameterList[] = $this->conn->quote($class->discriminatorValue);
         } else {
             $discrMap = array_flip($class->discriminatorMap);
             if (!isset($discrMap[$entityClassName])) {
                 throw QueryException::instanceOfUnrelatedClass($entityClassName, $class->rootEntityName);
             }
             $sqlParameterList[] = $this->conn->quote($discrMap[$entityClassName]);
         }
     }
     $sql .= '(' . implode(', ', $sqlParameterList) . ')';
     return $sql;
 }
開發者ID:nemekzg,項目名稱:doctrine2,代碼行數:43,代碼來源:SqlWalker.php

示例3: walkInstanceOfExpression

 /**
  * Walks down an InstanceOfExpression AST node, thereby generating the appropriate SQL.
  *
  * @param InstanceOfExpression
  * @return string The SQL.
  */
 public function walkInstanceOfExpression($instanceOfExpr)
 {
     $sql = '';
     $dqlAlias = $instanceOfExpr->identificationVariable;
     $discrClass = $class = $this->_queryComponents[$dqlAlias]['metadata'];
     $fieldName = null;
     if ($class->discriminatorColumn) {
         $discrClass = $this->_em->getClassMetadata($class->rootEntityName);
     }
     if ($this->_useSqlTableAliases) {
         $sql .= $this->getSQLTableAlias($discrClass->table['name'], $dqlAlias) . '.';
     }
     $sql .= $class->discriminatorColumn['name'] . ($instanceOfExpr->not ? ' <> ' : ' = ');
     if ($instanceOfExpr->value instanceof AST\InputParameter) {
         // We need to modify the parameter value to be its correspondent mapped value
         $dqlParamKey = $instanceOfExpr->value->name;
         $paramValue = $this->_query->getParameter($dqlParamKey);
         if (!$paramValue instanceof \Doctrine\ORM\Mapping\ClassMetadata) {
             throw QueryException::invalidParameterType('ClassMetadata', get_class($paramValue));
         }
         $entityClassName = $paramValue->name;
     } else {
         // Get name from ClassMetadata to resolve aliases.
         $entityClassName = $this->_em->getClassMetadata($instanceOfExpr->value)->name;
     }
     if ($entityClassName == $class->name) {
         $sql .= $this->_conn->quote($class->discriminatorValue);
     } else {
         $discrMap = array_flip($class->discriminatorMap);
         if (!isset($discrMap[$entityClassName])) {
             throw QueryException::instanceOfUnrelatedClass($entityClassName, $class->rootEntityName);
         }
         $sql .= $this->_conn->quote($discrMap[$entityClassName]);
     }
     return $sql;
 }
開發者ID:hermann106,項目名稱:PasaGlProject,代碼行數:42,代碼來源:SqlWalker.php


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