. */ namespace Doctrine\ORM\Query\AST\Functions; use Doctrine\ORM\Query\Lexer; /** * "IDENTITY" "(" SingleValuedAssociationPathExpression ")" * * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.doctrine-project.org * @since 2.2 * @author Guilherme Blanco * @author Benjamin Eberlei */ class IdentityFunction extends FunctionNode { public $pathExpression; /** * @override */ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); $dqlAlias = $this->pathExpression->identificationVariable; $assocField = $this->pathExpression->field; $qComp = $sqlWalker->getQueryComponent($dqlAlias); $class = $qComp['metadata']; $assoc = $class->associationMappings[$assocField]; $tableAlias = $sqlWalker->getSQLTableAlias($class->getTableName(), $dqlAlias); return $tableAlias . '.' . reset($assoc['targetToSourceKeyColumns']);; } /** * @override */ public function parse(\Doctrine\ORM\Query\Parser $parser) { $parser->match(Lexer::T_IDENTIFIER); $parser->match(Lexer::T_OPEN_PARENTHESIS); $this->pathExpression = $parser->SingleValuedAssociationPathExpression(); $parser->match(Lexer::T_CLOSE_PARENTHESIS); } }