我正在尝试更新注释实体中的字段“注释”,该字段与“ElementModule”和“Inscription”具有ManyToOne(双向)关系,实体“Inscription”与“Etudiant”实体具有ManyToOne关系
我尝试了这个 DQL 查询:
$query = $this->_em->createQuery('update UaePortailBundle:Note u JOIN u.inscription i JOIN u.elementmodule e join i.etudiant et set u.note = ?3
where et.id = ?1 and e.id = ?2 ');
$query->setParameter(1, $etudiant);
$query->setParameter(2, $element);
$query->setParameter(3, $note);
$resultat = $query->execute();
我收到此错误
[Syntax Error] line 0, col 50: Error: Expected Doctrine\ORM\Query\Lexer::T_EQUALS, got 'i'
最佳答案
LEFT JOIN,或者特别是 JOIN 仅在 MySQL 的 UPDATE 语句中受支持。 DQL 抽象了常见 ansi sql 的子集,因此这是不可能的。尝试使用子选择或 IDENTITY(您必须使用最新版本的 Doctrine 2.2.2):
createQuery('update UaePortailBundle:Note u set u.note = ?3
where IDNETITY(u.inscription) = ?1 and IDENTITY(u.elementmodule) = ?2 ');
关于symfony - 使用连接表更新学说,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10744432/