Error: Expected DoctrineORMQueryLexer::T_WITH, got #39;ON#39;(错误:预期的 DoctrineORMQueryLexer::T_WITH,“ON)
问题描述
我编写了以下用于从数据库中获取数据的代码:
I have written the following code for fetching data from database:
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));
} }
但它正在给予:
[语法错误] 第 0 行,第 203 行:错误:预期的 DoctrineORMQueryLexer::T_WITH,出现ON"500 内部服务器错误 - QueryException 1 链接异常:QueryException »
[Syntax Error] line 0, col 203: Error: Expected DoctrineORMQueryLexer::T_WITH, got 'ON' 500 Internal Server Error - QueryException 1 linked Exception: QueryException »
推荐答案
[Syntax Error] line 0, col 203: Error: Expected DoctrineORMQueryLexer::T_WITH, got 'ON' 500 Internal Server Error - QueryException 1 linked Exception: QueryException »
我认为您应该将关键字ON"替换为WITH".
I think you should replace your keyword 'ON' with a 'WITH' .
从文档中提取:
现在可以在 DQL 中使用任意实体之间的连接语法 FROM Foo f JOIN Bar b WITH f.id = b.id
.
Joins between arbitrary entities are now possible in DQL by using the syntax
FROM Foo f JOIN Bar b WITH f.id = b.id
.
这篇关于错误:预期的 DoctrineORMQueryLexer::T_WITH,“ON"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:错误:预期的 DoctrineORMQueryLexer::T_WITH,“ON"
基础教程推荐
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- 使用 PDO 转义列名 2021-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- PHP 守护进程/worker 环境 2022-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- HTTP 与 FTP 上传 2021-01-01