本文整理匯總了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;
}