CountOutputWalker
class CountOutputWalker extends SqlWalker
Wraps the query in order to accurately count the root objects.
Given a DQL like SELECT u FROM User u
it will generate an SQL query like:
SELECT COUNT(*) (SELECT DISTINCT
Works with composite keys but cannot deal with queries that have multiple
root entities (e.g. SELECT f, b from Foo, Bar
)
Methods
Constructor.
Walks down a SelectStatement AST node, wrapping it in a COUNT (SELECT DISTINCT).
Details
at line 58
__construct(Query $query, ParserResult $parserResult, array $queryComponents)
Constructor.
Stores various parameters that are otherwise unavailable because Doctrine\ORM\Query\SqlWalker keeps everything private without accessors.
at line 80
string
walkSelectStatement(SelectStatement $AST)
Walks down a SelectStatement AST node, wrapping it in a COUNT (SELECT DISTINCT).
Note that the ORDER BY clause is not removed. Many SQL implementations (e.g. MySQL) are able to cache subqueries. By keeping the ORDER BY clause intact, the limitSubQuery that will most likely be executed next can be read from the native SQL cache.