gpt4 book ai didi

mysql - Doctrine DQL - 预期字符串结尾,得到 'inner'

转载 作者:行者123 更新时间:2023-11-29 12:55:40 25 4
gpt4 key购买 nike

我正在尝试执行一些简单的查询,但我总是遇到此异常

[Syntax Error] line 0, col 157: Error: Expected end of string, got 'inner'

这是我的查询:

public function hasRecord($user, $event)
{
$q = $this->getEntityManager()->createQuery("
select count(h.id) from Tsk\FEBundle\Entity\History h
inner join h.user u where u.id = :user
inner join h.event v and v.id = :event
");

$q->setParameters([
"user" => $user,
"event" => $event
]);
return $q->getSingleScalarResult();
}

如何执行两个内部联接?我的查询有问题吗?

最佳答案

您应该在 where 子句之前进行连接:

public function hasRecord($user, $event)
{
$q = $this->getEntityManager()->createQuery("
select count(h.id) from Tsk\FEBundle\Entity\History h
inner join h.user u
inner join h.event v
where u.id = :user
and v.id = :event
");

$q->setParameters([
"user" => $user,
"event" => $event
]);
return $q->getSingleScalarResult();
}

关于mysql - Doctrine DQL - 预期字符串结尾,得到 'inner',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24091408/

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