class SqlWalker implements TreeWalker (View source)

The SqlWalker is a TreeWalker that walks over a DQL AST and constructs the corresponding SQL.

Constants

HINT_DISTINCT

Methods

__construct(AbstractQuery $query, ParserResult $parserResult, array $queryComponents)

Initializes TreeWalker with important information about the ASTs to be walked.

Query.
getQuery()

Gets the Query instance used by the walker.

Connection
getConnection()

Gets the Connection used by the walker.

getEntityManager()

Gets the EntityManager used by the walker.

array
getQueryComponent(string $dqlAlias)

Gets the information about a single query component.

array
getQueryComponents()

Returns internal queryComponents array.

void
setQueryComponent(string $dqlAlias, array $queryComponent)

Sets or overrides a query component for a given dql alias.

getExecutor(DeleteStatement|UpdateStatement|SelectStatement $AST)

Gets an executor that can be used to execute the result of this walker.

string
getSQLTableAlias(string $tableName, string $dqlAlias = '')

Generates a unique, short SQL table alias.

string
setSQLTableAlias(string $tableName, string $alias, string $dqlAlias = '')

Forces the SqlWalker to use a specific alias for a table name, rather than generating an alias on its own.

string
getSQLColumnAlias(string $columnName)

Gets an SQL column alias for a column name.

string
walkSelectStatement(SelectStatement $AST)

Walks down a SelectStatement AST node, thereby generating the appropriate SQL.

string
walkUpdateStatement(UpdateStatement $AST)

Walks down an UpdateStatement AST node, thereby generating the appropriate SQL.

string
walkDeleteStatement(DeleteStatement $AST)

Walks down a DeleteStatement AST node, thereby generating the appropriate SQL.

string
walkEntityIdentificationVariable(string $identVariable)

Walks down an IdentificationVariable AST node, thereby generating the appropriate SQL.

string
walkIdentificationVariable(string $identificationVariable, string $fieldName = null)

Walks down an IdentificationVariable (no AST node associated), thereby generating the SQL.

string
walkPathExpression(mixed $pathExpr)

Walks down a PathExpression AST node, thereby generating the appropriate SQL.

string
walkSelectClause(SelectClause $selectClause)

Walks down a SelectClause AST node, thereby generating the appropriate SQL.

string
walkFromClause(FromClause $fromClause)

Walks down a FromClause AST node, thereby generating the appropriate SQL.

string
walkIdentificationVariableDeclaration(IdentificationVariableDeclaration $identificationVariableDecl)

Walks down a IdentificationVariableDeclaration AST node, thereby generating the appropriate SQL.

void
walkIndexBy(IndexBy $indexBy)

Walks down a IndexBy AST node.

string
walkRangeVariableDeclaration(RangeVariableDeclaration $rangeVariableDeclaration)

Walks down a RangeVariableDeclaration AST node, thereby generating the appropriate SQL.

string
walkJoinAssociationDeclaration(JoinAssociationDeclaration $joinAssociationDeclaration, int $joinType = AST\Join::JOIN_TYPE_INNER, ConditionalExpression $condExpr = null)

Walks down a JoinAssociationDeclaration AST node, thereby generating the appropriate SQL.

string
walkFunction(FunctionNode $function)

Walks down a FunctionNode AST node, thereby generating the appropriate SQL.

string
walkOrderByClause(OrderByClause $orderByClause)

Walks down an OrderByClause AST node, thereby generating the appropriate SQL.

string
walkOrderByItem(OrderByItem $orderByItem)

Walks down an OrderByItem AST node, thereby generating the appropriate SQL.

string
walkHavingClause(HavingClause $havingClause)

Walks down a HavingClause AST node, thereby generating the appropriate SQL.

string
walkJoin(Join $join)

Walks down a Join AST node and creates the corresponding SQL.

string
walkCaseExpression(CoalesceExpression|NullIfExpression|GeneralCaseExpression|SimpleCaseExpression $expression)

Walks down a CaseExpression AST node and generates the corresponding SQL.

string
walkCoalesceExpression(CoalesceExpression $coalesceExpression)

Walks down a CoalesceExpression AST node and generates the corresponding SQL.

string
walkNullIfExpression(NullIfExpression $nullIfExpression)

Walks down a NullIfExpression AST node and generates the corresponding SQL.

string
walkGeneralCaseExpression(GeneralCaseExpression $generalCaseExpression)

Walks down a GeneralCaseExpression AST node and generates the corresponding SQL.

string
walkSimpleCaseExpression(SimpleCaseExpression $simpleCaseExpression)

Walks down a SimpleCaseExpression AST node and generates the corresponding SQL.

string
walkSelectExpression(SelectExpression $selectExpression)

Walks down a SelectExpression AST node and generates the corresponding SQL.

string
walkQuantifiedExpression(QuantifiedExpression $qExpr)

Walks down a QuantifiedExpression AST node, thereby generating the appropriate SQL.

string
walkSubselect(Subselect $subselect)

Walks down a Subselect AST node, thereby generating the appropriate SQL.

string
walkSubselectFromClause(SubselectFromClause $subselectFromClause)

Walks down a SubselectFromClause AST node, thereby generating the appropriate SQL.

string
walkSimpleSelectClause(SimpleSelectClause $simpleSelectClause)

Walks down a SimpleSelectClause AST node, thereby generating the appropriate SQL.

string.
walkParenthesisExpression(ParenthesisExpression $parenthesisExpression)

No description

string
walkNewObject($newObjectExpression, $newObjectResultAlias = null)

No description

string
walkSimpleSelectExpression(SimpleSelectExpression $simpleSelectExpression)

Walks down a SimpleSelectExpression AST node, thereby generating the appropriate SQL.

string
walkAggregateExpression(AggregateExpression $aggExpression)

Walks down an AggregateExpression AST node, thereby generating the appropriate SQL.

string
walkGroupByClause(GroupByClause $groupByClause)

Walks down a GroupByClause AST node, thereby generating the appropriate SQL.

string
walkGroupByItem(PathExpression|string $groupByItem)

Walks down a GroupByItem AST node, thereby generating the appropriate SQL.

string
walkDeleteClause(DeleteClause $deleteClause)

Walks down a DeleteClause AST node, thereby generating the appropriate SQL.

string
walkUpdateClause(UpdateClause $updateClause)

Walks down an UpdateClause AST node, thereby generating the appropriate SQL.

string
walkUpdateItem(UpdateItem $updateItem)

Walks down an UpdateItem AST node, thereby generating the appropriate SQL.

string
walkWhereClause(WhereClause $whereClause)

Walks down a WhereClause AST node, thereby generating the appropriate SQL.

string
walkConditionalExpression(ConditionalExpression $condExpr)

Walk down a ConditionalExpression AST node, thereby generating the appropriate SQL.

string
walkConditionalTerm(ConditionalTerm $condTerm)

Walks down a ConditionalTerm AST node, thereby generating the appropriate SQL.

string
walkConditionalFactor(ConditionalFactor $factor)

Walks down a ConditionalFactor AST node, thereby generating the appropriate SQL.

string
walkConditionalPrimary(ConditionalPrimary $primary)

Walks down a ConditionalPrimary AST node, thereby generating the appropriate SQL.

string
walkExistsExpression(ExistsExpression $existsExpr)

Walks down an ExistsExpression AST node, thereby generating the appropriate SQL.

string
walkCollectionMemberExpression(CollectionMemberExpression $collMemberExpr)

Walks down a CollectionMemberExpression AST node, thereby generating the appropriate SQL.

string
walkEmptyCollectionComparisonExpression(EmptyCollectionComparisonExpression $emptyCollCompExpr)

Walks down an EmptyCollectionComparisonExpression AST node, thereby generating the appropriate SQL.

string
walkNullComparisonExpression(NullComparisonExpression $nullCompExpr)

Walks down a NullComparisonExpression AST node, thereby generating the appropriate SQL.

string
walkInExpression(InExpression $inExpr)

Walks down an InExpression AST node, thereby generating the appropriate SQL.

string
walkInstanceOfExpression(InstanceOfExpression $instanceOfExpr)

Walks down an InstanceOfExpression AST node, thereby generating the appropriate SQL.

walkInParameter($inParam)

{@inheritdoc}

string
walkLiteral(mixed $literal)

Walks down a literal that represents an AST node, thereby generating the appropriate SQL.

string
walkBetweenExpression(BetweenExpression $betweenExpr)

Walks down a BetweenExpression AST node, thereby generating the appropriate SQL.

string
walkLikeExpression(LikeExpression $likeExpr)

Walks down a LikeExpression AST node, thereby generating the appropriate SQL.

string
walkStateFieldPathExpression(PathExpression $stateFieldPathExpression)

Walks down a StateFieldPathExpression AST node, thereby generating the appropriate SQL.

string
walkComparisonExpression(ComparisonExpression $compExpr)

Walks down a ComparisonExpression AST node, thereby generating the appropriate SQL.

string
walkInputParameter(InputParameter $inputParam)

Walks down an InputParameter AST node, thereby generating the appropriate SQL.

string
walkArithmeticExpression(ArithmeticExpression $arithmeticExpr)

Walks down an ArithmeticExpression AST node, thereby generating the appropriate SQL.

string
walkSimpleArithmeticExpression(SimpleArithmeticExpression $simpleArithmeticExpr)

Walks down an SimpleArithmeticExpression AST node, thereby generating the appropriate SQL.

string
walkArithmeticTerm(mixed $term)

Walks down an ArithmeticTerm AST node, thereby generating the appropriate SQL.

string
walkArithmeticFactor(mixed $factor)

Walks down an ArithmeticFactor that represents an AST node, thereby generating the appropriate SQL.

string
walkArithmeticPrimary(mixed $primary)

Walks down an ArithmeticPrimary that represents an AST node, thereby generating the appropriate SQL.

string
walkStringPrimary(mixed $stringPrimary)

Walks down a StringPrimary that represents an AST node, thereby generating the appropriate SQL.

string
walkResultVariable(string $resultVariable)

Walks down a ResultVariable that represents an AST node, thereby generating the appropriate SQL.

Details

__construct(AbstractQuery $query, ParserResult $parserResult, array $queryComponents)

Initializes TreeWalker with important information about the ASTs to be walked.

Parameters

AbstractQuery $query The parsed Query.
ParserResult $parserResult The result of the parsing process.
array $queryComponents The query components (symbol table).

Query. getQuery()

Gets the Query instance used by the walker.

Return Value

Query.

Connection getConnection()

Gets the Connection used by the walker.

Return Value

Connection

EntityManager getEntityManager()

Gets the EntityManager used by the walker.

Return Value

EntityManager

array getQueryComponent(string $dqlAlias)

Gets the information about a single query component.

Parameters

string $dqlAlias The DQL alias.

Return Value

array

array getQueryComponents()

Returns internal queryComponents array.

Return Value

array

void setQueryComponent(string $dqlAlias, array $queryComponent)

Sets or overrides a query component for a given dql alias.

Parameters

string $dqlAlias The DQL alias.
array $queryComponent

Return Value

void

AbstractSqlExecutor getExecutor(DeleteStatement|UpdateStatement|SelectStatement $AST)

Gets an executor that can be used to execute the result of this walker.

string getSQLTableAlias(string $tableName, string $dqlAlias = '')

Generates a unique, short SQL table alias.

Parameters

string $tableName Table name
string $dqlAlias The DQL alias.

Return Value

string Generated table alias.

string setSQLTableAlias(string $tableName, string $alias, string $dqlAlias = '')

Forces the SqlWalker to use a specific alias for a table name, rather than generating an alias on its own.

Parameters

string $tableName
string $alias
string $dqlAlias

Return Value

string

string getSQLColumnAlias(string $columnName)

Gets an SQL column alias for a column name.

Parameters

string $columnName

Return Value

string

string walkSelectStatement(SelectStatement $AST)

Walks down a SelectStatement AST node, thereby generating the appropriate SQL.

Parameters

SelectStatement $AST

Return Value

string The SQL.

string walkUpdateStatement(UpdateStatement $AST)

Walks down an UpdateStatement AST node, thereby generating the appropriate SQL.

Parameters

UpdateStatement $AST

Return Value

string The SQL.

string walkDeleteStatement(DeleteStatement $AST)

Walks down a DeleteStatement AST node, thereby generating the appropriate SQL.

Parameters

DeleteStatement $AST

Return Value

string The SQL.

string walkEntityIdentificationVariable(string $identVariable)

Walks down an IdentificationVariable AST node, thereby generating the appropriate SQL.

This one differs of ->walkIdentificationVariable() because it generates the entity identifiers.

Parameters

string $identVariable

Return Value

string

string walkIdentificationVariable(string $identificationVariable, string $fieldName = null)

Walks down an IdentificationVariable (no AST node associated), thereby generating the SQL.

Parameters

string $identificationVariable
string $fieldName

Return Value

string The SQL.

string walkPathExpression(mixed $pathExpr)

Walks down a PathExpression AST node, thereby generating the appropriate SQL.

Parameters

mixed $pathExpr

Return Value

string The SQL.

string walkSelectClause(SelectClause $selectClause)

Walks down a SelectClause AST node, thereby generating the appropriate SQL.

Parameters

SelectClause $selectClause

Return Value

string The SQL.

string walkFromClause(FromClause $fromClause)

Walks down a FromClause AST node, thereby generating the appropriate SQL.

Parameters

FromClause $fromClause

Return Value

string The SQL.

string walkIdentificationVariableDeclaration(IdentificationVariableDeclaration $identificationVariableDecl)

Walks down a IdentificationVariableDeclaration AST node, thereby generating the appropriate SQL.

Parameters

IdentificationVariableDeclaration $identificationVariableDecl

Return Value

string

void walkIndexBy(IndexBy $indexBy)

Walks down a IndexBy AST node.

Parameters

IndexBy $indexBy

Return Value

void

string walkRangeVariableDeclaration(RangeVariableDeclaration $rangeVariableDeclaration)

Walks down a RangeVariableDeclaration AST node, thereby generating the appropriate SQL.

Parameters

RangeVariableDeclaration $rangeVariableDeclaration

Return Value

string

string walkJoinAssociationDeclaration(JoinAssociationDeclaration $joinAssociationDeclaration, int $joinType = AST\Join::JOIN_TYPE_INNER, ConditionalExpression $condExpr = null)

Walks down a JoinAssociationDeclaration AST node, thereby generating the appropriate SQL.

Parameters

JoinAssociationDeclaration $joinAssociationDeclaration
int $joinType
ConditionalExpression $condExpr

Return Value

string

Exceptions

QueryException

string walkFunction(FunctionNode $function)

Walks down a FunctionNode AST node, thereby generating the appropriate SQL.

Parameters

FunctionNode $function

Return Value

string The SQL.

string walkOrderByClause(OrderByClause $orderByClause)

Walks down an OrderByClause AST node, thereby generating the appropriate SQL.

Parameters

OrderByClause $orderByClause

Return Value

string The SQL.

string walkOrderByItem(OrderByItem $orderByItem)

Walks down an OrderByItem AST node, thereby generating the appropriate SQL.

Parameters

OrderByItem $orderByItem

Return Value

string The SQL.

string walkHavingClause(HavingClause $havingClause)

Walks down a HavingClause AST node, thereby generating the appropriate SQL.

Parameters

HavingClause $havingClause

Return Value

string The SQL.

string walkJoin(Join $join)

Walks down a Join AST node and creates the corresponding SQL.

Parameters

Join $join

Return Value

string The SQL.

string walkCaseExpression(CoalesceExpression|NullIfExpression|GeneralCaseExpression|SimpleCaseExpression $expression)

Walks down a CaseExpression AST node and generates the corresponding SQL.

Parameters

CoalesceExpression|NullIfExpression|GeneralCaseExpression|SimpleCaseExpression $expression

Return Value

string The SQL.

string walkCoalesceExpression(CoalesceExpression $coalesceExpression)

Walks down a CoalesceExpression AST node and generates the corresponding SQL.

Parameters

CoalesceExpression $coalesceExpression

Return Value

string The SQL.

string walkNullIfExpression(NullIfExpression $nullIfExpression)

Walks down a NullIfExpression AST node and generates the corresponding SQL.

Parameters

NullIfExpression $nullIfExpression

Return Value

string The SQL.

string walkGeneralCaseExpression(GeneralCaseExpression $generalCaseExpression)

Walks down a GeneralCaseExpression AST node and generates the corresponding SQL.

Parameters

GeneralCaseExpression $generalCaseExpression

Return Value

string The SQL.

string walkSimpleCaseExpression(SimpleCaseExpression $simpleCaseExpression)

Walks down a SimpleCaseExpression AST node and generates the corresponding SQL.

Parameters

SimpleCaseExpression $simpleCaseExpression

Return Value

string The SQL.

string walkSelectExpression(SelectExpression $selectExpression)

Walks down a SelectExpression AST node and generates the corresponding SQL.

Parameters

SelectExpression $selectExpression

Return Value

string The SQL.

string walkQuantifiedExpression(QuantifiedExpression $qExpr)

Walks down a QuantifiedExpression AST node, thereby generating the appropriate SQL.

Parameters

QuantifiedExpression $qExpr

Return Value

string The SQL.

string walkSubselect(Subselect $subselect)

Walks down a Subselect AST node, thereby generating the appropriate SQL.

Parameters

Subselect $subselect

Return Value

string The SQL.

string walkSubselectFromClause(SubselectFromClause $subselectFromClause)

Walks down a SubselectFromClause AST node, thereby generating the appropriate SQL.

Parameters

SubselectFromClause $subselectFromClause

Return Value

string The SQL.

string walkSimpleSelectClause(SimpleSelectClause $simpleSelectClause)

Walks down a SimpleSelectClause AST node, thereby generating the appropriate SQL.

Parameters

SimpleSelectClause $simpleSelectClause

Return Value

string The SQL.

string. walkParenthesisExpression(ParenthesisExpression $parenthesisExpression)

Parameters

ParenthesisExpression $parenthesisExpression

Return Value

string.

string walkNewObject($newObjectExpression, $newObjectResultAlias = null)

Parameters

$newObjectExpression
$newObjectResultAlias

Return Value

string The SQL.

string walkSimpleSelectExpression(SimpleSelectExpression $simpleSelectExpression)

Walks down a SimpleSelectExpression AST node, thereby generating the appropriate SQL.

Parameters

SimpleSelectExpression $simpleSelectExpression

Return Value

string The SQL.

string walkAggregateExpression(AggregateExpression $aggExpression)

Walks down an AggregateExpression AST node, thereby generating the appropriate SQL.

Parameters

AggregateExpression $aggExpression

Return Value

string The SQL.

string walkGroupByClause(GroupByClause $groupByClause)

Walks down a GroupByClause AST node, thereby generating the appropriate SQL.

Parameters

GroupByClause $groupByClause

Return Value

string The SQL.

string walkGroupByItem(PathExpression|string $groupByItem)

Walks down a GroupByItem AST node, thereby generating the appropriate SQL.

Parameters

PathExpression|string $groupByItem

Return Value

string The SQL.

string walkDeleteClause(DeleteClause $deleteClause)

Walks down a DeleteClause AST node, thereby generating the appropriate SQL.

Parameters

DeleteClause $deleteClause

Return Value

string The SQL.

string walkUpdateClause(UpdateClause $updateClause)

Walks down an UpdateClause AST node, thereby generating the appropriate SQL.

Parameters

UpdateClause $updateClause

Return Value

string The SQL.

string walkUpdateItem(UpdateItem $updateItem)

Walks down an UpdateItem AST node, thereby generating the appropriate SQL.

Parameters

UpdateItem $updateItem

Return Value

string The SQL.

string walkWhereClause(WhereClause $whereClause)

Walks down a WhereClause AST node, thereby generating the appropriate SQL.

WhereClause or not, the appropriate discriminator sql is added.

Parameters

WhereClause $whereClause

Return Value

string The SQL.

string walkConditionalExpression(ConditionalExpression $condExpr)

Walk down a ConditionalExpression AST node, thereby generating the appropriate SQL.

Parameters

ConditionalExpression $condExpr

Return Value

string The SQL.

string walkConditionalTerm(ConditionalTerm $condTerm)

Walks down a ConditionalTerm AST node, thereby generating the appropriate SQL.

Parameters

ConditionalTerm $condTerm

Return Value

string The SQL.

string walkConditionalFactor(ConditionalFactor $factor)

Walks down a ConditionalFactor AST node, thereby generating the appropriate SQL.

Parameters

ConditionalFactor $factor

Return Value

string The SQL.

string walkConditionalPrimary(ConditionalPrimary $primary)

Walks down a ConditionalPrimary AST node, thereby generating the appropriate SQL.

Parameters

ConditionalPrimary $primary

Return Value

string The SQL.

string walkExistsExpression(ExistsExpression $existsExpr)

Walks down an ExistsExpression AST node, thereby generating the appropriate SQL.

Parameters

ExistsExpression $existsExpr

Return Value

string The SQL.

string walkCollectionMemberExpression(CollectionMemberExpression $collMemberExpr)

Walks down a CollectionMemberExpression AST node, thereby generating the appropriate SQL.

Parameters

CollectionMemberExpression $collMemberExpr

Return Value

string The SQL.

string walkEmptyCollectionComparisonExpression(EmptyCollectionComparisonExpression $emptyCollCompExpr)

Walks down an EmptyCollectionComparisonExpression AST node, thereby generating the appropriate SQL.

Parameters

EmptyCollectionComparisonExpression $emptyCollCompExpr

Return Value

string The SQL.

string walkNullComparisonExpression(NullComparisonExpression $nullCompExpr)

Walks down a NullComparisonExpression AST node, thereby generating the appropriate SQL.

Parameters

NullComparisonExpression $nullCompExpr

Return Value

string The SQL.

string walkInExpression(InExpression $inExpr)

Walks down an InExpression AST node, thereby generating the appropriate SQL.

Parameters

InExpression $inExpr

Return Value

string The SQL.

string walkInstanceOfExpression(InstanceOfExpression $instanceOfExpr)

Walks down an InstanceOfExpression AST node, thereby generating the appropriate SQL.

Parameters

InstanceOfExpression $instanceOfExpr

Return Value

string The SQL.

walkInParameter($inParam)

{@inheritdoc}

Parameters

$inParam

string walkLiteral(mixed $literal)

Walks down a literal that represents an AST node, thereby generating the appropriate SQL.

Parameters

mixed $literal

Return Value

string The SQL.

string walkBetweenExpression(BetweenExpression $betweenExpr)

Walks down a BetweenExpression AST node, thereby generating the appropriate SQL.

Parameters

BetweenExpression $betweenExpr

Return Value

string The SQL.

string walkLikeExpression(LikeExpression $likeExpr)

Walks down a LikeExpression AST node, thereby generating the appropriate SQL.

Parameters

LikeExpression $likeExpr

Return Value

string The SQL.

string walkStateFieldPathExpression(PathExpression $stateFieldPathExpression)

Walks down a StateFieldPathExpression AST node, thereby generating the appropriate SQL.

Parameters

PathExpression $stateFieldPathExpression

Return Value

string The SQL.

string walkComparisonExpression(ComparisonExpression $compExpr)

Walks down a ComparisonExpression AST node, thereby generating the appropriate SQL.

Parameters

ComparisonExpression $compExpr

Return Value

string The SQL.

string walkInputParameter(InputParameter $inputParam)

Walks down an InputParameter AST node, thereby generating the appropriate SQL.

Parameters

InputParameter $inputParam

Return Value

string The SQL.

string walkArithmeticExpression(ArithmeticExpression $arithmeticExpr)

Walks down an ArithmeticExpression AST node, thereby generating the appropriate SQL.

Parameters

ArithmeticExpression $arithmeticExpr

Return Value

string The SQL.

string walkSimpleArithmeticExpression(SimpleArithmeticExpression $simpleArithmeticExpr)

Walks down an SimpleArithmeticExpression AST node, thereby generating the appropriate SQL.

Parameters

SimpleArithmeticExpression $simpleArithmeticExpr

Return Value

string The SQL.

string walkArithmeticTerm(mixed $term)

Walks down an ArithmeticTerm AST node, thereby generating the appropriate SQL.

Parameters

mixed $term

Return Value

string The SQL.

string walkArithmeticFactor(mixed $factor)

Walks down an ArithmeticFactor that represents an AST node, thereby generating the appropriate SQL.

Parameters

mixed $factor

Return Value

string The SQL.

string walkArithmeticPrimary(mixed $primary)

Walks down an ArithmeticPrimary that represents an AST node, thereby generating the appropriate SQL.

Parameters

mixed $primary

Return Value

string The SQL.

string walkStringPrimary(mixed $stringPrimary)

Walks down a StringPrimary that represents an AST node, thereby generating the appropriate SQL.

Parameters

mixed $stringPrimary

Return Value

string The SQL.

string walkResultVariable(string $resultVariable)

Walks down a ResultVariable that represents an AST node, thereby generating the appropriate SQL.

Parameters

string $resultVariable

Return Value

string The SQL.