class Parser (View source)

An LL(*) recursive-descent parser for the context-free grammar of the Doctrine Query Language.

Parses a DQL query, reports any errors in it, and generates an AST.

Methods

static bool
isInternalFunction(string $functionName)

Checks if a function is internally defined. Used to prevent overwriting of built-in functions through user-defined functions.

__construct(Query $query)

Creates a new query parser object.

void
setCustomOutputTreeWalker(string $className)

Sets a custom tree walker that produces output.

void
addCustomTreeWalker(string $className)

Adds a custom tree walker for modifying the AST.

getLexer()

Gets the lexer used by the parser.

getParserResult()

Gets the ParserResult that is being filled with information during parsing.

getEntityManager()

Gets the EntityManager used by the parser.

getAST()

Parses and builds AST for the given Query.

void
match(int $token)

Attempts to match the given token with the current lookahead token.

void
free(boolean $deep = false, integer $position = 0)

Frees this parser, enabling it to be reused.

parse()

Parses a query string.

void
syntaxError(string $expected = '', array|null $token = null)

Generates a new syntax error.

void
semanticalError(string $message = '', array|null $token = null)

Generates a new semantical error.

QueryLanguage()

QueryLanguage ::= SelectStatement | UpdateStatement | DeleteStatement

SelectStatement()

SelectStatement ::= SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]

UpdateStatement()

UpdateStatement ::= UpdateClause [WhereClause]

DeleteStatement()

DeleteStatement ::= DeleteClause [WhereClause]

string
IdentificationVariable()

IdentificationVariable ::= identifier

string
AliasIdentificationVariable()

AliasIdentificationVariable = identifier

string
AbstractSchemaName()

AbstractSchemaName ::= identifier

string
AliasResultVariable()

AliasResultVariable ::= identifier

string
ResultVariable()

ResultVariable ::= identifier

JoinAssociationPathExpression()

JoinAssociationPathExpression ::= IdentificationVariable "." (CollectionValuedAssociationField | SingleValuedAssociationField)

PathExpression(integer $expectedTypes)

Parses an arbitrary path expression and defers semantical validation based on expected types.

AssociationPathExpression()

AssociationPathExpression ::= CollectionValuedPathExpression | SingleValuedAssociationPathExpression

SingleValuedPathExpression()

SingleValuedPathExpression ::= StateFieldPathExpression | SingleValuedAssociationPathExpression

StateFieldPathExpression()

StateFieldPathExpression ::= IdentificationVariable "." StateField

SingleValuedAssociationPathExpression()

SingleValuedAssociationPathExpression ::= IdentificationVariable "." SingleValuedAssociationField

CollectionValuedPathExpression()

CollectionValuedPathExpression ::= IdentificationVariable "." CollectionValuedAssociationField

SelectClause()

SelectClause ::= "SELECT" ["DISTINCT"] SelectExpression {"," SelectExpression}

SimpleSelectClause()

SimpleSelectClause ::= "SELECT" ["DISTINCT"] SimpleSelectExpression

UpdateClause()

UpdateClause ::= "UPDATE" AbstractSchemaName ["AS"] AliasIdentificationVariable "SET" UpdateItem {"," UpdateItem}*

DeleteClause()

DeleteClause ::= "DELETE" ["FROM"] AbstractSchemaName ["AS"] AliasIdentificationVariable

FromClause()

FromClause ::= "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration}*

SubselectFromClause()

SubselectFromClause ::= "FROM" SubselectIdentificationVariableDeclaration {"," SubselectIdentificationVariableDeclaration}*

WhereClause()

WhereClause ::= "WHERE" ConditionalExpression

HavingClause()

HavingClause ::= "HAVING" ConditionalExpression

GroupByClause()

GroupByClause ::= "GROUP" "BY" GroupByItem {"," GroupByItem}*

OrderByClause()

OrderByClause ::= "ORDER" "BY" OrderByItem {"," OrderByItem}*

Subselect()

Subselect ::= SimpleSelectClause SubselectFromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]

UpdateItem()

UpdateItem ::= SingleValuedPathExpression "=" NewValue

string
GroupByItem()

GroupByItem ::= IdentificationVariable | ResultVariable | SingleValuedPathExpression

OrderByItem()

OrderByItem ::= ( SimpleArithmeticExpression | SingleValuedPathExpression | ScalarExpression | ResultVariable | FunctionDeclaration ) ["ASC" | "DESC"]

NewValue()

NewValue ::= SimpleArithmeticExpression | StringPrimary | DatetimePrimary | BooleanPrimary | EnumPrimary | SimpleEntityExpression | "NULL"

IdentificationVariableDeclaration()

IdentificationVariableDeclaration ::= RangeVariableDeclaration [IndexBy] {Join}*

SubselectIdentificationVariableDeclaration()

SubselectIdentificationVariableDeclaration ::= IdentificationVariableDeclaration

Join()

Join ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN" (JoinAssociationDeclaration | RangeVariableDeclaration) ["WITH" ConditionalExpression]

RangeVariableDeclaration()

RangeVariableDeclaration ::= AbstractSchemaName ["AS"] AliasIdentificationVariable

JoinAssociationDeclaration()

JoinAssociationDeclaration ::= JoinAssociationPathExpression ["AS"] AliasIdentificationVariable [IndexBy]

array
PartialObjectExpression()

PartialObjectExpression ::= "PARTIAL" IdentificationVariable "." PartialFieldSet PartialFieldSet ::= "{" SimpleStateField {"," SimpleStateField}* "}"

NewObjectExpression()

NewObjectExpression ::= "NEW" IdentificationVariable "(" NewObjectArg {"," NewObjectArg}* ")"

mixed
NewObjectArg()

NewObjectArg ::= ScalarExpression | "(" Subselect ")"

IndexBy()

IndexBy ::= "INDEX" "BY" StateFieldPathExpression

mixed
ScalarExpression()

ScalarExpression ::= SimpleArithmeticExpression | StringPrimary | DateTimePrimary | StateFieldPathExpression | BooleanPrimary | CaseExpression | InstanceOfExpression

mixed
CaseExpression()

CaseExpression ::= GeneralCaseExpression | SimpleCaseExpression | CoalesceExpression | NullifExpression GeneralCaseExpression ::= "CASE" WhenClause {WhenClause}* "ELSE" ScalarExpression "END" WhenClause ::= "WHEN" ConditionalExpression "THEN" ScalarExpression SimpleCaseExpression ::= "CASE" CaseOperand SimpleWhenClause {SimpleWhenClause}* "ELSE" ScalarExpression "END" CaseOperand ::= StateFieldPathExpression | TypeDiscriminator SimpleWhenClause ::= "WHEN" ScalarExpression "THEN" ScalarExpression CoalesceExpression ::= "COALESCE" "(" ScalarExpression {"," ScalarExpression}* ")" NullifExpression ::= "NULLIF" "(" ScalarExpression "," ScalarExpression ")"

CoalesceExpression()

CoalesceExpression ::= "COALESCE" "(" ScalarExpression {"," ScalarExpression}* ")"

NullIfExpression()

NullIfExpression ::= "NULLIF" "(" ScalarExpression "," ScalarExpression ")"

GeneralCaseExpression()

GeneralCaseExpression ::= "CASE" WhenClause {WhenClause}* "ELSE" ScalarExpression "END"

SimpleCaseExpression()

SimpleCaseExpression ::= "CASE" CaseOperand SimpleWhenClause {SimpleWhenClause}* "ELSE" ScalarExpression "END" CaseOperand ::= StateFieldPathExpression | TypeDiscriminator

WhenClause()

WhenClause ::= "WHEN" ConditionalExpression "THEN" ScalarExpression

SimpleWhenClause()

SimpleWhenClause ::= "WHEN" ScalarExpression "THEN" ScalarExpression

SelectExpression()

SelectExpression ::= ( IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | "(" Subselect ")" | CaseExpression | NewObjectExpression ) [["AS"] ["HIDDEN"] AliasResultVariable]

SimpleSelectExpression()

SimpleSelectExpression ::= ( StateFieldPathExpression | IdentificationVariable | FunctionDeclaration | AggregateExpression | "(" Subselect ")" | ScalarExpression ) [["AS"] AliasResultVariable]

ConditionalExpression()

ConditionalExpression ::= ConditionalTerm {"OR" ConditionalTerm}*

ConditionalTerm()

ConditionalTerm ::= ConditionalFactor {"AND" ConditionalFactor}*

ConditionalFactor()

ConditionalFactor ::= ["NOT"] ConditionalPrimary

ConditionalPrimary()

ConditionalPrimary ::= SimpleConditionalExpression | "(" ConditionalExpression ")"

SimpleConditionalExpression()

SimpleConditionalExpression ::= ComparisonExpression | BetweenExpression | LikeExpression | InExpression | NullComparisonExpression | ExistsExpression | EmptyCollectionComparisonExpression | CollectionMemberExpression | InstanceOfExpression

EmptyCollectionComparisonExpression()

EmptyCollectionComparisonExpression ::= CollectionValuedPathExpression "IS" ["NOT"] "EMPTY"

CollectionMemberExpression()

CollectionMemberExpression ::= EntityExpression ["NOT"] "MEMBER" ["OF"] CollectionValuedPathExpression

Literal()

Literal ::= string | char | integer | float | boolean

string
InParameter()

InParameter ::= Literal | InputParameter

InputParameter()

InputParameter ::= PositionalParameter | NamedParameter

ArithmeticExpression()

ArithmeticExpression ::= SimpleArithmeticExpression | "(" Subselect ")"

SimpleArithmeticExpression()

SimpleArithmeticExpression ::= ArithmeticTerm {("+" | "-") ArithmeticTerm}*

ArithmeticTerm()

ArithmeticTerm ::= ArithmeticFactor {("" | "/") ArithmeticFactor}

ArithmeticFactor()

ArithmeticFactor ::= [("+" | "-")] ArithmeticPrimary

ArithmeticPrimary()

ArithmeticPrimary ::= SingleValuedPathExpression | Literal | ParenthesisExpression | FunctionsReturningNumerics | AggregateExpression | FunctionsReturningStrings | FunctionsReturningDatetime | IdentificationVariable | ResultVariable | InputParameter | CaseExpression

StringPrimary
StringExpression()

StringExpression ::= StringPrimary | ResultVariable | "(" Subselect ")"

StringPrimary()

StringPrimary ::= StateFieldPathExpression | string | InputParameter | FunctionsReturningStrings | AggregateExpression | CaseExpression

SingleValuedAssociationPathExpression
EntityExpression()

EntityExpression ::= SingleValuedAssociationPathExpression | SimpleEntityExpression

string
SimpleEntityExpression()

SimpleEntityExpression ::= IdentificationVariable | InputParameter

AggregateExpression()

AggregateExpression ::= ("AVG" | "MAX" | "MIN" | "SUM" | "COUNT") "(" ["DISTINCT"] SimpleArithmeticExpression ")"

QuantifiedExpression()

QuantifiedExpression ::= ("ALL" | "ANY" | "SOME") "(" Subselect ")"

BetweenExpression()

BetweenExpression ::= ArithmeticExpression ["NOT"] "BETWEEN" ArithmeticExpression "AND" ArithmeticExpression

ComparisonExpression()

ComparisonExpression ::= ArithmeticExpression ComparisonOperator ( QuantifiedExpression | ArithmeticExpression )

InExpression()

InExpression ::= SingleValuedPathExpression ["NOT"] "IN" "(" (InParameter {"," InParameter}* | Subselect) ")"

InstanceOfExpression()

InstanceOfExpression ::= IdentificationVariable ["NOT"] "INSTANCE" ["OF"] (InstanceOfParameter | "(" InstanceOfParameter {"," InstanceOfParameter}* ")")

mixed
InstanceOfParameter()

InstanceOfParameter ::= AbstractSchemaName | InputParameter

LikeExpression()

LikeExpression ::= StringExpression ["NOT"] "LIKE" StringPrimary ["ESCAPE" char]

NullComparisonExpression()

NullComparisonExpression ::= (InputParameter | NullIfExpression | CoalesceExpression | AggregateExpression | FunctionDeclaration | IdentificationVariable | SingleValuedPathExpression | ResultVariable) "IS" ["NOT"] "NULL"

ExistsExpression()

ExistsExpression ::= ["NOT"] "EXISTS" "(" Subselect ")"

string
ComparisonOperator()

ComparisonOperator ::= "=" | "<" | "<=" | "<>" | ">" | ">=" | "!="

FunctionDeclaration()

FunctionDeclaration ::= FunctionsReturningStrings | FunctionsReturningNumerics | FunctionsReturningDatetime

FunctionsReturningNumerics()

FunctionsReturningNumerics ::= "LENGTH" "(" StringPrimary ")" | "LOCATE" "(" StringPrimary "," StringPrimary ["," SimpleArithmeticExpression]")" | "ABS" "(" SimpleArithmeticExpression ")" | "SQRT" "(" SimpleArithmeticExpression ")" | "MOD" "(" SimpleArithmeticExpression "," SimpleArithmeticExpression ")" | "SIZE" "(" CollectionValuedPathExpression ")" | "DATE_DIFF" "(" ArithmeticPrimary "," ArithmeticPrimary ")" | "BIT_AND" "(" ArithmeticPrimary "," ArithmeticPrimary ")" | "BIT_OR" "(" ArithmeticPrimary "," ArithmeticPrimary ")"

FunctionsReturningDatetime()

FunctionsReturningDateTime ::= "CURRENT_DATE" | "CURRENT_TIME" | "CURRENT_TIMESTAMP" | "DATE_ADD" "(" ArithmeticPrimary "," ArithmeticPrimary "," StringPrimary ")" | "DATE_SUB" "(" ArithmeticPrimary "," ArithmeticPrimary "," StringPrimary ")"

FunctionsReturningStrings()

FunctionsReturningStrings ::= "CONCAT" "(" StringPrimary "," StringPrimary ")" | "SUBSTRING" "(" StringPrimary "," SimpleArithmeticExpression "," SimpleArithmeticExpression ")" | "TRIM" "(" [["LEADING" | "TRAILING" | "BOTH"] [char] "FROM"] StringPrimary ")" | "LOWER" "(" StringPrimary ")" | "UPPER" "(" StringPrimary ")" | "IDENTITY" "(" SingleValuedAssociationPathExpression {"," string} ")"

Details

static bool isInternalFunction(string $functionName)

Checks if a function is internally defined. Used to prevent overwriting of built-in functions through user-defined functions.

Parameters

string $functionName

Return Value

bool

__construct(Query $query)

Creates a new query parser object.

Parameters

Query $query The Query to parse.

void setCustomOutputTreeWalker(string $className)

Sets a custom tree walker that produces output.

This tree walker will be run last over the AST, after any other walkers.

Parameters

string $className

Return Value

void

void addCustomTreeWalker(string $className)

Adds a custom tree walker for modifying the AST.

Parameters

string $className

Return Value

void

Lexer getLexer()

Gets the lexer used by the parser.

Return Value

Lexer

ParserResult getParserResult()

Gets the ParserResult that is being filled with information during parsing.

Return Value

ParserResult

EntityManager getEntityManager()

Gets the EntityManager used by the parser.

Return Value

EntityManager

SelectStatement getAST()

Parses and builds AST for the given Query.

Return Value

SelectStatement | \Doctrine\ORM\Query\AST\UpdateStatement | \Doctrine\ORM\Query\AST\DeleteStatement

void match(int $token)

Attempts to match the given token with the current lookahead token.

If they match, updates the lookahead token; otherwise raises a syntax error.

Parameters

int $token The token type.

Return Value

void

Exceptions

QueryException If the tokens don't match.

void free(boolean $deep = false, integer $position = 0)

Frees this parser, enabling it to be reused.

Parameters

boolean $deep Whether to clean peek and reset errors.
integer $position Position to reset.

Return Value

void

ParserResult parse()

Parses a query string.

Return Value

ParserResult

void syntaxError(string $expected = '', array|null $token = null)

Generates a new syntax error.

Parameters

string $expected Expected string.
array|null $token Got token.

Return Value

void

Exceptions

QueryException

void semanticalError(string $message = '', array|null $token = null)

Generates a new semantical error.

Parameters

string $message Optional message.
array|null $token Optional token.

Return Value

void

Exceptions

QueryException

SelectStatement QueryLanguage()

QueryLanguage ::= SelectStatement | UpdateStatement | DeleteStatement

Return Value

SelectStatement | \Doctrine\ORM\Query\AST\UpdateStatement | \Doctrine\ORM\Query\AST\DeleteStatement

SelectStatement SelectStatement()

SelectStatement ::= SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]

Return Value

SelectStatement

UpdateStatement UpdateStatement()

UpdateStatement ::= UpdateClause [WhereClause]

Return Value

UpdateStatement

DeleteStatement DeleteStatement()

DeleteStatement ::= DeleteClause [WhereClause]

Return Value

DeleteStatement

string IdentificationVariable()

IdentificationVariable ::= identifier

Return Value

string

string AliasIdentificationVariable()

AliasIdentificationVariable = identifier

Return Value

string

string AbstractSchemaName()

AbstractSchemaName ::= identifier

Return Value

string

string AliasResultVariable()

AliasResultVariable ::= identifier

Return Value

string

string ResultVariable()

ResultVariable ::= identifier

Return Value

string

JoinAssociationPathExpression JoinAssociationPathExpression()

JoinAssociationPathExpression ::= IdentificationVariable "." (CollectionValuedAssociationField | SingleValuedAssociationField)

PathExpression PathExpression(integer $expectedTypes)

Parses an arbitrary path expression and defers semantical validation based on expected types.

PathExpression ::= IdentificationVariable {"." identifier}*

Parameters

integer $expectedTypes

Return Value

PathExpression

PathExpression AssociationPathExpression()

AssociationPathExpression ::= CollectionValuedPathExpression | SingleValuedAssociationPathExpression

Return Value

PathExpression

PathExpression SingleValuedPathExpression()

SingleValuedPathExpression ::= StateFieldPathExpression | SingleValuedAssociationPathExpression

Return Value

PathExpression

PathExpression StateFieldPathExpression()

StateFieldPathExpression ::= IdentificationVariable "." StateField

Return Value

PathExpression

PathExpression SingleValuedAssociationPathExpression()

SingleValuedAssociationPathExpression ::= IdentificationVariable "." SingleValuedAssociationField

Return Value

PathExpression

PathExpression CollectionValuedPathExpression()

CollectionValuedPathExpression ::= IdentificationVariable "." CollectionValuedAssociationField

Return Value

PathExpression

SelectClause SelectClause()

SelectClause ::= "SELECT" ["DISTINCT"] SelectExpression {"," SelectExpression}

Return Value

SelectClause

SimpleSelectClause SimpleSelectClause()

SimpleSelectClause ::= "SELECT" ["DISTINCT"] SimpleSelectExpression

Return Value

SimpleSelectClause

UpdateClause UpdateClause()

UpdateClause ::= "UPDATE" AbstractSchemaName ["AS"] AliasIdentificationVariable "SET" UpdateItem {"," UpdateItem}*

Return Value

UpdateClause

DeleteClause DeleteClause()

DeleteClause ::= "DELETE" ["FROM"] AbstractSchemaName ["AS"] AliasIdentificationVariable

Return Value

DeleteClause

FromClause FromClause()

FromClause ::= "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration}*

Return Value

FromClause

SubselectFromClause SubselectFromClause()

SubselectFromClause ::= "FROM" SubselectIdentificationVariableDeclaration {"," SubselectIdentificationVariableDeclaration}*

Return Value

SubselectFromClause

WhereClause WhereClause()

WhereClause ::= "WHERE" ConditionalExpression

Return Value

WhereClause

HavingClause HavingClause()

HavingClause ::= "HAVING" ConditionalExpression

Return Value

HavingClause

GroupByClause GroupByClause()

GroupByClause ::= "GROUP" "BY" GroupByItem {"," GroupByItem}*

Return Value

GroupByClause

OrderByClause OrderByClause()

OrderByClause ::= "ORDER" "BY" OrderByItem {"," OrderByItem}*

Return Value

OrderByClause

Subselect Subselect()

Subselect ::= SimpleSelectClause SubselectFromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]

Return Value

Subselect

UpdateItem UpdateItem()

UpdateItem ::= SingleValuedPathExpression "=" NewValue

Return Value

UpdateItem

string GroupByItem()

GroupByItem ::= IdentificationVariable | ResultVariable | SingleValuedPathExpression

Return Value

string | \Doctrine\ORM\Query\AST\PathExpression

OrderByItem OrderByItem()

OrderByItem ::= ( SimpleArithmeticExpression | SingleValuedPathExpression | ScalarExpression | ResultVariable | FunctionDeclaration ) ["ASC" | "DESC"]

Return Value

OrderByItem

ArithmeticExpression NewValue()

NewValue ::= SimpleArithmeticExpression | StringPrimary | DatetimePrimary | BooleanPrimary | EnumPrimary | SimpleEntityExpression | "NULL"

NOTE: Since it is not possible to correctly recognize individual types, here is the full grammar that needs to be supported:

NewValue ::= SimpleArithmeticExpression | "NULL"

SimpleArithmeticExpression covers all *Primary grammar rules and also SimpleEntityExpression

Return Value

ArithmeticExpression

IdentificationVariableDeclaration IdentificationVariableDeclaration()

IdentificationVariableDeclaration ::= RangeVariableDeclaration [IndexBy] {Join}*

SubselectIdentificationVariableDeclaration SubselectIdentificationVariableDeclaration()

SubselectIdentificationVariableDeclaration ::= IdentificationVariableDeclaration

{Internal note: WARNING: Solution is harder than a bare implementation. Desired EBNF support:

SubselectIdentificationVariableDeclaration ::= IdentificationVariableDeclaration | (AssociationPathExpression ["AS"] AliasIdentificationVariable)

It demands that entire SQL generation to become programmatical. This is needed because association based subselect requires "WHERE" conditional expressions to be injected, but there is no scope to do that. Only scope accessible is "FROM", prohibiting an easy implementation without larger changes.}

Return Value

SubselectIdentificationVariableDeclaration | \Doctrine\ORM\Query\AST\IdentificationVariableDeclaration

Join Join()

Join ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN" (JoinAssociationDeclaration | RangeVariableDeclaration) ["WITH" ConditionalExpression]

Return Value

Join

RangeVariableDeclaration RangeVariableDeclaration()

RangeVariableDeclaration ::= AbstractSchemaName ["AS"] AliasIdentificationVariable

JoinAssociationPathExpression JoinAssociationDeclaration()

JoinAssociationDeclaration ::= JoinAssociationPathExpression ["AS"] AliasIdentificationVariable [IndexBy]

array PartialObjectExpression()

PartialObjectExpression ::= "PARTIAL" IdentificationVariable "." PartialFieldSet PartialFieldSet ::= "{" SimpleStateField {"," SimpleStateField}* "}"

Return Value

array

NewObjectExpression NewObjectExpression()

NewObjectExpression ::= "NEW" IdentificationVariable "(" NewObjectArg {"," NewObjectArg}* ")"

Return Value

NewObjectExpression

mixed NewObjectArg()

NewObjectArg ::= ScalarExpression | "(" Subselect ")"

Return Value

mixed

IndexBy IndexBy()

IndexBy ::= "INDEX" "BY" StateFieldPathExpression

Return Value

IndexBy

mixed ScalarExpression()

ScalarExpression ::= SimpleArithmeticExpression | StringPrimary | DateTimePrimary | StateFieldPathExpression | BooleanPrimary | CaseExpression | InstanceOfExpression

Return Value

mixed One of the possible expressions or subexpressions.

mixed CaseExpression()

CaseExpression ::= GeneralCaseExpression | SimpleCaseExpression | CoalesceExpression | NullifExpression GeneralCaseExpression ::= "CASE" WhenClause {WhenClause}* "ELSE" ScalarExpression "END" WhenClause ::= "WHEN" ConditionalExpression "THEN" ScalarExpression SimpleCaseExpression ::= "CASE" CaseOperand SimpleWhenClause {SimpleWhenClause}* "ELSE" ScalarExpression "END" CaseOperand ::= StateFieldPathExpression | TypeDiscriminator SimpleWhenClause ::= "WHEN" ScalarExpression "THEN" ScalarExpression CoalesceExpression ::= "COALESCE" "(" ScalarExpression {"," ScalarExpression}* ")" NullifExpression ::= "NULLIF" "(" ScalarExpression "," ScalarExpression ")"

Return Value

mixed One of the possible expressions or subexpressions.

CoalesceExpression CoalesceExpression()

CoalesceExpression ::= "COALESCE" "(" ScalarExpression {"," ScalarExpression}* ")"

Return Value

CoalesceExpression

NullIfExpression NullIfExpression()

NullIfExpression ::= "NULLIF" "(" ScalarExpression "," ScalarExpression ")"

Return Value

NullIfExpression

GeneralCaseExpression GeneralCaseExpression()

GeneralCaseExpression ::= "CASE" WhenClause {WhenClause}* "ELSE" ScalarExpression "END"

Return Value

GeneralCaseExpression

SimpleCaseExpression SimpleCaseExpression()

SimpleCaseExpression ::= "CASE" CaseOperand SimpleWhenClause {SimpleWhenClause}* "ELSE" ScalarExpression "END" CaseOperand ::= StateFieldPathExpression | TypeDiscriminator

Return Value

SimpleCaseExpression

WhenClause WhenClause()

WhenClause ::= "WHEN" ConditionalExpression "THEN" ScalarExpression

Return Value

WhenClause

SimpleWhenClause SimpleWhenClause()

SimpleWhenClause ::= "WHEN" ScalarExpression "THEN" ScalarExpression

Return Value

SimpleWhenClause

SelectExpression SelectExpression()

SelectExpression ::= ( IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | "(" Subselect ")" | CaseExpression | NewObjectExpression ) [["AS"] ["HIDDEN"] AliasResultVariable]

Return Value

SelectExpression

SimpleSelectExpression SimpleSelectExpression()

SimpleSelectExpression ::= ( StateFieldPathExpression | IdentificationVariable | FunctionDeclaration | AggregateExpression | "(" Subselect ")" | ScalarExpression ) [["AS"] AliasResultVariable]

Return Value

SimpleSelectExpression

ConditionalExpression ConditionalExpression()

ConditionalExpression ::= ConditionalTerm {"OR" ConditionalTerm}*

Return Value

ConditionalExpression

ConditionalTerm ConditionalTerm()

ConditionalTerm ::= ConditionalFactor {"AND" ConditionalFactor}*

Return Value

ConditionalTerm

ConditionalFactor ConditionalFactor()

ConditionalFactor ::= ["NOT"] ConditionalPrimary

Return Value

ConditionalFactor

ConditionalPrimary ConditionalPrimary()

ConditionalPrimary ::= SimpleConditionalExpression | "(" ConditionalExpression ")"

Return Value

ConditionalPrimary

SimpleConditionalExpression()

SimpleConditionalExpression ::= ComparisonExpression | BetweenExpression | LikeExpression | InExpression | NullComparisonExpression | ExistsExpression | EmptyCollectionComparisonExpression | CollectionMemberExpression | InstanceOfExpression

EmptyCollectionComparisonExpression EmptyCollectionComparisonExpression()

EmptyCollectionComparisonExpression ::= CollectionValuedPathExpression "IS" ["NOT"] "EMPTY"

CollectionMemberExpression CollectionMemberExpression()

CollectionMemberExpression ::= EntityExpression ["NOT"] "MEMBER" ["OF"] CollectionValuedPathExpression

EntityExpression ::= SingleValuedAssociationPathExpression | SimpleEntityExpression SimpleEntityExpression ::= IdentificationVariable | InputParameter

Literal Literal()

Literal ::= string | char | integer | float | boolean

Return Value

Literal

string InParameter()

InParameter ::= Literal | InputParameter

Return Value

string | \Doctrine\ORM\Query\AST\InputParameter

InputParameter InputParameter()

InputParameter ::= PositionalParameter | NamedParameter

Return Value

InputParameter

ArithmeticExpression ArithmeticExpression()

ArithmeticExpression ::= SimpleArithmeticExpression | "(" Subselect ")"

Return Value

ArithmeticExpression

SimpleArithmeticExpression SimpleArithmeticExpression()

SimpleArithmeticExpression ::= ArithmeticTerm {("+" | "-") ArithmeticTerm}*

ArithmeticTerm ArithmeticTerm()

ArithmeticTerm ::= ArithmeticFactor {("" | "/") ArithmeticFactor}

Return Value

ArithmeticTerm

ArithmeticFactor ArithmeticFactor()

ArithmeticFactor ::= [("+" | "-")] ArithmeticPrimary

Return Value

ArithmeticFactor

ArithmeticPrimary()

ArithmeticPrimary ::= SingleValuedPathExpression | Literal | ParenthesisExpression | FunctionsReturningNumerics | AggregateExpression | FunctionsReturningStrings | FunctionsReturningDatetime | IdentificationVariable | ResultVariable | InputParameter | CaseExpression

StringPrimary StringExpression()

StringExpression ::= StringPrimary | ResultVariable | "(" Subselect ")"

Return Value

StringPrimary | \Doctrine\ORM\Query\AST\Subselect | string

StringPrimary()

StringPrimary ::= StateFieldPathExpression | string | InputParameter | FunctionsReturningStrings | AggregateExpression | CaseExpression

SingleValuedAssociationPathExpression EntityExpression()

EntityExpression ::= SingleValuedAssociationPathExpression | SimpleEntityExpression

Return Value

SingleValuedAssociationPathExpression | \Doctrine\ORM\Query\AST\SimpleEntityExpression

string SimpleEntityExpression()

SimpleEntityExpression ::= IdentificationVariable | InputParameter

Return Value

string | \Doctrine\ORM\Query\AST\InputParameter

AggregateExpression AggregateExpression()

AggregateExpression ::= ("AVG" | "MAX" | "MIN" | "SUM" | "COUNT") "(" ["DISTINCT"] SimpleArithmeticExpression ")"

Return Value

AggregateExpression

QuantifiedExpression QuantifiedExpression()

QuantifiedExpression ::= ("ALL" | "ANY" | "SOME") "(" Subselect ")"

Return Value

QuantifiedExpression

BetweenExpression BetweenExpression()

BetweenExpression ::= ArithmeticExpression ["NOT"] "BETWEEN" ArithmeticExpression "AND" ArithmeticExpression

Return Value

BetweenExpression

ComparisonExpression ComparisonExpression()

ComparisonExpression ::= ArithmeticExpression ComparisonOperator ( QuantifiedExpression | ArithmeticExpression )

Return Value

ComparisonExpression

InExpression InExpression()

InExpression ::= SingleValuedPathExpression ["NOT"] "IN" "(" (InParameter {"," InParameter}* | Subselect) ")"

Return Value

InExpression

InstanceOfExpression InstanceOfExpression()

InstanceOfExpression ::= IdentificationVariable ["NOT"] "INSTANCE" ["OF"] (InstanceOfParameter | "(" InstanceOfParameter {"," InstanceOfParameter}* ")")

Return Value

InstanceOfExpression

mixed InstanceOfParameter()

InstanceOfParameter ::= AbstractSchemaName | InputParameter

Return Value

mixed

LikeExpression LikeExpression()

LikeExpression ::= StringExpression ["NOT"] "LIKE" StringPrimary ["ESCAPE" char]

Return Value

LikeExpression

NullComparisonExpression NullComparisonExpression()

NullComparisonExpression ::= (InputParameter | NullIfExpression | CoalesceExpression | AggregateExpression | FunctionDeclaration | IdentificationVariable | SingleValuedPathExpression | ResultVariable) "IS" ["NOT"] "NULL"

ExistsExpression ExistsExpression()

ExistsExpression ::= ["NOT"] "EXISTS" "(" Subselect ")"

Return Value

ExistsExpression

string ComparisonOperator()

ComparisonOperator ::= "=" | "<" | "<=" | "<>" | ">" | ">=" | "!="

Return Value

string

FunctionNode FunctionDeclaration()

FunctionDeclaration ::= FunctionsReturningStrings | FunctionsReturningNumerics | FunctionsReturningDatetime

Return Value

FunctionNode

FunctionNode FunctionsReturningNumerics()

FunctionsReturningNumerics ::= "LENGTH" "(" StringPrimary ")" | "LOCATE" "(" StringPrimary "," StringPrimary ["," SimpleArithmeticExpression]")" | "ABS" "(" SimpleArithmeticExpression ")" | "SQRT" "(" SimpleArithmeticExpression ")" | "MOD" "(" SimpleArithmeticExpression "," SimpleArithmeticExpression ")" | "SIZE" "(" CollectionValuedPathExpression ")" | "DATE_DIFF" "(" ArithmeticPrimary "," ArithmeticPrimary ")" | "BIT_AND" "(" ArithmeticPrimary "," ArithmeticPrimary ")" | "BIT_OR" "(" ArithmeticPrimary "," ArithmeticPrimary ")"

Return Value

FunctionNode

FunctionNode CustomFunctionsReturningNumerics()

Return Value

FunctionNode

FunctionNode FunctionsReturningDatetime()

FunctionsReturningDateTime ::= "CURRENT_DATE" | "CURRENT_TIME" | "CURRENT_TIMESTAMP" | "DATE_ADD" "(" ArithmeticPrimary "," ArithmeticPrimary "," StringPrimary ")" | "DATE_SUB" "(" ArithmeticPrimary "," ArithmeticPrimary "," StringPrimary ")"

Return Value

FunctionNode

FunctionNode CustomFunctionsReturningDatetime()

Return Value

FunctionNode

FunctionNode FunctionsReturningStrings()

FunctionsReturningStrings ::= "CONCAT" "(" StringPrimary "," StringPrimary ")" | "SUBSTRING" "(" StringPrimary "," SimpleArithmeticExpression "," SimpleArithmeticExpression ")" | "TRIM" "(" [["LEADING" | "TRAILING" | "BOTH"] [char] "FROM"] StringPrimary ")" | "LOWER" "(" StringPrimary ")" | "UPPER" "(" StringPrimary ")" | "IDENTITY" "(" SingleValuedAssociationPathExpression {"," string} ")"

Return Value

FunctionNode

FunctionNode CustomFunctionsReturningStrings()

Return Value

FunctionNode