Upon making a change in my database, I'm to delete some related entries in another table.
I made a custom query in my Repository:
public function removeOptionGc(VarianteEscalier $varianteEscalier) {
$em=$this->getEntityManager();
return $em->createQueryBuilder()
->delete(VarianteEscalierOptGc::class, "vogc")
->join("vogc.gardecorpsOption", "gco")
->where("vogc.varianteEscalier=:VARIANTE")
->andWhere("gco.type='option_gc_rampant' OR gco.type='option_gc_etage' OR gco.type='autres'")
->setParameters(array('VARIANTE'=>$varianteEscalier))
->getQuery()
->getResult();
}
When I execute it, I will get the following error:
[Semantical Error] line 0, col 94 near 'gco.type='option_gc_rampant'': Error: 'gco' is not defined.
This is the DQL I get from this query:
DELETE AppBundle\Entity\VarianteEscalierOptGc vogc WHERE vogc.varianteEscalier=:VARIANTE AND (gco.type='option_gc_rampant' OR gco.type='option_gc_etage' OR gco.type='autres')
Any idea as to why join
is ignored when I try a delete
?
From one of the developer of Doctrine itself, the answer is that many vendors do not support JOIN
in INSERT
, UPDATE
and DELETE
statements, and Doctrine does not include features that are not cross-platforms (almost verbatim what he said).
See full discussion: https://github.com/doctrine/dbal/issues/2716