Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. public function findByVerificacion($usuario, $salon){
  2. $em = $this->getEntityManager();
  3.  
  4. $consulta = $em->createQuery('
  5. SELECT p.id, p.fechaInicio, p.fechaFin
  6. FROM SalonesBundle:PrestamoSalon p
  7. WHERE p.users = :usuario AND p.sala = :salon
  8. ');
  9.  
  10. $consulta->setParameter('usuario',$usuario);
  11. $consulta->setParameter('salon',$salon);
  12. $consulta->setMaxResults(1);
  13. $consulta->getResult();
  14.  
  15. return $consulta;
  16. }
  17.  
  18. $iden = $consulta[0]['id'] //segun la guia de doctrine;
  19. $iden = $consulta->'id'
  20. $iden = $consulta->getId();
  21.  
  22. public function verificarPrestamoAction(Request $request){
  23.  
  24. $id = $request->request->get('iden');
  25. $salon = $request->request->get('salones');
  26.  
  27. $em = $this->getDoctrine()->getEntityManager();
  28.  
  29. $consulta = $em->getRepository('SalonesBundle:PrestamoSalon')->findByVerificacion($id,$salon);
  30.  
  31. if(!$consulta){
  32. return $this->render('@Salones/PrestamoSalon/tools/resultado.html.twig', array(
  33. 'mensaje' => 'El usuario no tiene un prestamo activo en este salon'
  34. ));
  35. }
  36.  
  37. return $this->render('@Salones/PrestamoSalon/tools/resultado.html.twig', array(
  38. 'mensaje' => 'El usuario tiene un prestamo activo en este salon.'
  39. ));
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement