作者热门文章
- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我编写了以下代码用于从数据库中获取数据:
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/
我是一名优秀的程序员,十分优秀!