Doctrine QueryBuilder Methods Cheat Sheet
I've put together this quick QueryBuilder cheat sheet so you don't have to dig through Doctrine docs or source code every time you need a method reference. Contents Overview: SELECT: Field selectio...

Source: DEV Community
I've put together this quick QueryBuilder cheat sheet so you don't have to dig through Doctrine docs or source code every time you need a method reference. Contents Overview: SELECT: Field selection and DISTINCT options; FROM & JOIN: Table setup and join types (INNER, LEFT, RIGHT); WHERE/HAVING: Conditions with AND/OR logic; GROUP/ORDER: Grouping, sorting with reset controls; CRUD: INSERT, UPDATE, DELETE operations; Advanced: UNION (DBAL 4.x), CTE, LIMIT/OFFSET, caching. 1. SELECT select(string ...$expressions) — Defines SELECT fields, overwriting any previous selection. // SELECT u.id, u.name, u.email FROM ... $qb->select('u.id', 'u.name', 'u.email'); addSelect(string $expression, string ...$expressions) — Appends fields to existing SELECT clause. // SELECT u.id, p.title, p.content FROM ... $qb->select('u.id')->addSelect('p.title', 'p.content'); distinct(bool $distinct = true) — Adds/removes DISTINCT to eliminate duplicate rows. // SELECT DISTINCT u.city FROM ... $qb->