本文整理汇总了PHP中Doctrine\ORM\Query::getAST方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::getAST方法的具体用法?PHP Query::getAST怎么用?PHP Query::getAST使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Query
的用法示例。
在下文中一共展示了Query::getAST方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEntityFromAlias
/**
* Resolve DQL alias into class metadata
*
* @param Doctrine\ORM\Query $query
* @param string $alias
* @return array | null
*/
protected function getEntityFromAlias($query, $alias = null)
{
$em = $query->getEntityManager();
$ast = $query->getAST();
$fromClause = $ast->fromClause;
foreach ($fromClause->identificationVariableDeclarations as $root) {
$className = $root->rangeVariableDeclaration->abstractSchemaName;
$classAlias = $root->rangeVariableDeclaration->aliasIdentificationVariable;
if ($classAlias == $alias || null === $alias) {
return array('alias' => $classAlias, 'metadata' => $em->getClassMetadata($className));
} else {
foreach ($root->joins as $join) {
$joinAlias = $join->joinAssociationDeclaration->aliasIdentificationVariable;
$joinField = $join->joinAssociationDeclaration->joinAssociationPathExpression->associationField;
$joinParent = $join->joinAssociationDeclaration->joinAssociationPathExpression->identificationVariable;
if ($joinAlias == $alias) {
if ($joinParent != $classAlias) {
$data = $this->getEntityFromAlias($query, $joinParent);
$metadata = $data['metadata'];
} else {
$metadata = $em->getClassMetadata($className);
}
$joinName = $metadata->associationMappings[$joinField]['targetEntity'];
return array('alias' => $joinAlias, 'metadata' => $em->getClassMetadata($joinName));
}
}
}
}
return null;
}