Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. public function updateCourse($studentid){
  2. return $this->getEntityManager()
  3. ->createQuery(
  4. 'select * from AcmeDemoBundle: Course
  5. where startDate= :startDate or endDate= :endDate
  6. UPDATE AcmeDemoBundle:Course
  7. SET Course.payrollperiodid=Student.payrollperiodid
  8. FROM
  9. Student
  10. WHERE
  11. Course.startDate=Student.startDate or Course.endDate=Student.endDate'
  12. )
  13. ->setParameter()
  14. ->getResults();
  15. }
  16.  
  17. public function createAction(Request $request)
  18. {
  19. $entity = new Student();
  20. $form = $this->createCreateForm($entity);
  21. $form->handleRequest($request);
  22.  
  23. if ($form->isValid()) {
  24. $em = $this->getDoctrine()->getManager();
  25. $entity = $em->getRepository('AcmeDeomBundle:Student')->updateCourse();
  26. if (!$entity){
  27. $this->addFlash('error','ERROR! Student Record doesn't match Course Record');
  28. return $this->redirect($this->generateUrl('student_create'));
  29. }
  30. $em->persist($entity);
  31. $em->flush();
  32. return $this->redirect($this->generateUrl('student_show', array('studentid' => $entity->getstudentid())));
  33. }
  34. return array(
  35. 'entity' => $entity,
  36. 'form' => $form->createView(), );
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement