gpt4 book ai didi

mysql - DQL 更新多个表

转载 作者:行者123 更新时间:2023-11-29 07:53:12 24 4
gpt4 key购买 nike

我正在尝试更新一个查询中某些表中的一行。我已经完成了:

        $this->getDoctrine()->getManager()
->createQuery('
UPDATE eo, tw FROM
ProEntityOneBundle:EntityOne eo,
ProEntityTwoBundle:EntityTwo tw
SET eo.propertyOne = :newProperty,
tw.propertyTwo = :newProperty
WHERE eo.propertyOne = :oldProperty
AND tw.propertyTwo = :oldProperty')
->setParameters(array('newProperty' => $newProperty, 'oldProperty' => $oldProperty))
->execute();

但我收到此错误:

[Semantical Error] line 0, col 24 near 'eo, tw': Error: Class 'eo' is not defined.

我做错了什么?是否可以使用 DQL 在一个查询中更新某些表?

最佳答案

这是不可能的。每个 Doctrine 查询都映射到针对数据库执行的单个 SQL 语句,并且您不能在一条语句中更新多个表。

关于mysql - DQL 更新多个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25864735/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com