Advertisement
Guest User

Untitled

a guest
Dec 28th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. /**
  2. * @Route("/test/")
  3. */
  4. public function indexAction(){
  5. $em = $this->getDoctrine()->getManager();
  6. $przedmiots = $em->getRepository('AppBundle:Przedmiot')->findAll();
  7. $query = $em->createQuery(
  8.  
  9. //'SELECT p FROM AppBundle:Przedmiot p ORDER BY p.nazwa ASC'
  10.  
  11. 'SELECT SUM(p.laboratoriumLiczbaGodz) FROM AppBundle:Przydzial p WHERE p.idPrzedmiot = 2'
  12. );
  13. $suma = $query->getResult();
  14. //$przydzials = $query->setMaxResults(1)->getOneOrNullResult();
  15.  
  16. return $this->render('statystyki/index.html.twig', array(
  17. 'suma' => $suma[0],'przedmiots' => $przedmiots,
  18. ));
  19. }
  20.  
  21.  
  22. w Twigu:
  23.  
  24. {% for suma in suma %}
  25.  
  26. {{ suma }}
  27.  
  28. {% endfor %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement