generate from create php symfony doctrine-orm

php - from - symfony 3.4 generate entity



Error: se esperaba "Doctrine / ORM / Query / Lexer:: T_WITH" (2)

He escrito el siguiente código para obtener datos de la base de datos:

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)); } }

Pero está dando:

[Error de sintaxis] línea 0, columna 203: Error: Se esperaba Doctrine / ORM / Query / Lexer :: T_WITH, se activó ''500'' Error interno del servidor - QueryException 1 excepción Excepción: QueryException »


Por favor use el código de abajo su trabajo para usted

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 WITH 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 »

Creo que deberías reemplazar tu palabra clave ''ON'' con un ''WITH''.

extracto de doc:

Las combinaciones entre entidades arbitrarias ahora son posibles en DQL usando la sintaxis FROM Foo f JOIN Bar b WITH f.id = b.id