16. The QueryBuilder — Doctrine 2 ORM 2 documentation
A QueryBuilder provides an API that is designed for conditionally constructing a DQL query in several steps. It provides a set of classes and methods that is able to programmatically build queries, and also provides a fluent API. This means that you can change between one methodology to the other as you want, and also pick one if you prefer. 16.1. Constructing a new QueryBuilder object The same way you build a normal Query, you build a QueryBuilder object, just providing the correct method name. <? Once you have created an instance of QueryBuilder, it provides a set of useful informative functions that you can use. <? There’re currently 3 possible return values for getType(): QueryBuilder::SELECT, which returns value 0QueryBuilder::DELETE, returning value 1QueryBuilder::UPDATE, which returns value 2 It is possible to retrieve the associated EntityManager of the current QueryBuilder, its DQL and also a Query object when you finish building your DQL. <? 16.2. 16.2.1. <? <? 16.2.2. <? <? <? <? 16.2.3.
Related: Symfony 2