gpt4 book ai didi

php - 错误:预期的 Doctrine\ORM\Query\Lexer::T_WITH,得到 'ON'

转载 作者:IT王子 更新时间:2023-10-29 00:00:45 25 4
gpt4 key购买 nike

我编写了以下代码用于从数据库中获取数据:

function getnotificationAction()
{
$session = $this->getRequest()->getSession();
$userId = $session->get('userid');

$entitymanager = $this->getDoctrine()->getEntityManager();
$notification = $entitymanager->getRepository('IGCNotificationBundle:Notifications');
$userNotification = $entitymanager->getRepository('IGCNotificationBundle:Usernotifications');
$query = $entitymanager
->createQuery("SELECT n.notificationid, n.title,n.notificationmessage, u.creationdate, u.notificationid, u.messagestatus From IGCNotificationBundle:Notifications AS n JOIN IGCNotificationBundle:Usernotifications AS u ON u.notificationid = n.notificationid WHERE u.userId = :userId ORDER BY n.creationdate DESC")->setParameter('userId', userId);

$notifications = $query->getResult();

return $this->render('IGCNotificationBundle:Default:notification.html.twig', array('notifications' => $notifications));
} }

但它正在给予:

[Syntax Error] line 0, col 203: Error: Expected Doctrine\ORM\Query\Lexer::T_WITH, got 'ON' 500 Internal Server Error - QueryException 1 linked Exception: QueryException »

最佳答案

[Syntax Error] line 0, col 203: Error: Expected Doctrine\ORM\Query\Lexer::T_WITH, got 'ON' 500 Internal Server Error - QueryException 1 linked Exception: QueryException »

我认为您应该将关键字“ON”替换为“WITH”。

文档摘录:

Joins between arbitrary entities are now possible in DQL by using the syntax FROM Foo f JOIN Bar b WITH f.id = b.id.

关于php - 错误:预期的 Doctrine\ORM\Query\Lexer::T_WITH,得到 'ON',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20467428/

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