Doctrine Query Builder not working with UPDATE and INNER JOIN

后端 未结 4 1374
没有蜡笔的小新
没有蜡笔的小新 2020-12-19 03:40

In my repository I have this query:

$qb = $this->getEntityManager()->createQueryBuilder();
$qb
    ->update(\'MyBundle:Entity1\', \'e1\') 
    ->         


        
4条回答
  •  生来不讨喜
    2020-12-19 04:06

    You can not use join on update and delete queries. You have to use subqueries.

    Joins are not supported on update and delete queries because it is not supported on all dbms. It won't be implemented in Doctrine 1 or Doctrine 2. You can however get the same affect by using subqueries.

    http://www.doctrine-project.org/jira/browse/DC-646

    If you are using MySQL, using subqueries will not work. You will have then to use 2 queries.

    In MySQL, you cannot modify a table and select from the same table in a subquery

    http://dev.mysql.com/doc/refman/5.0/en/subqueries.html

提交回复
热议问题