Issue Bug Closed

#81822Allow to clone QueryBuilder

Tymoteusz Motylewski 07/08/17, 17:34 updated 10/02/18, 10:58

Description

The Doctrine query builder supports cloning, so should our Query Builder, which is just a wrapper around it.

$newQueryBuilder = clone $queryBuilder;

Cloning of the query builder is useful when e.g. implementing pagination where process looks usually like:

- User provides query builder without limit and page
- pagination takes the query builder, clones it, changes the select part to “count(*)” to get the count of the results
- pagination takes the original query builder adds a limit and offset, and executes the query

Reviews 2