What's new

Doctrine query builder (Doctrine\DBAL) delete with inner join not working


Active member
Staff member
I have two tables:
users with fields id, project_id
projects with fields id, description
and project_id is foreign key.

I want to a delete method using Doctrine\DBAL\Query:

public function deleteUsers(int $projectId): void
$conn = $this->_em->getConnection();
$qb = $conn->createQueryBuilder();
->from('users', 'u')
->innerJoin('u', 'projects', 'p', 'u.project_id = p.id')
->where('p.id= :projectId');
$qb->setParameter('projectId', $projectId);

and I get:

string(39) "DELETE FROM u WHERE u.project_id = :projectId"

I don't undestand why not appear the INNER JOIN.
What is the sintax error?

Continue reading...