Deleting Data (delete)
delete is ObjectQuel's bulk, set-based delete statement — QUEL's delete verb, run directly against the database through the same EntityManager::executeQuery() entry point as retrieve and the DDL statements on Creating, Altering & Destroying Tables & Indexes. It bypasses the identity map and change tracking entirely. If you need entity lifecycle behavior — cascades, events, per-object optimistic-lock exceptions — use remove()/flush() instead. See also append, replace, and upsert.
Deleting Data with delete
delete requires an explicit where, so every delete statement is scoped to exactly the rows it names:
$result = $entityManager->executeQuery('
range of u is App\Entities\UserEntity
delete u where u.id = :id
', ['id' => $id]);
$result->getAffectedRows(); // number of rows deleted
Working with the Result
delete returns a QuelResult with no fetchable rows — getAffectedRows()
is the accessor that matters here, in place of iterating the result the way a retrieve result
is iterated. getGeneratedId() is always null for delete; see
append for statements where it's populated.
Scope & Limitations
deletetargets a single declared range — no join across multiple ranges.delete'swhereis mandatory; there is no "affects every row" shorthand.
Soft Delete
If the target entity carries @Orm\SoftDelete, delete compiles to an UPDATE that marks the matching rows deleted instead of a real DELETE — the same rule remove() follows. Add @ignoreSoftDelete true to force a real DELETE regardless. See Soft Delete for the full picture, including how this interacts with cascade and how to restore a soft-deleted row.
// Entity has @Orm\SoftDelete — becomes an UPDATE, row stays
$entityManager->executeQuery('
range of o is App\Entities\OrderEntity
delete o where o.id = :id
');
// Force a real DELETE regardless of @SoftDelete
$entityManager->executeQuery('
@ignoreSoftDelete true
range of o is App\Entities\OrderEntity
delete o where o.id = :id
');