Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function updateCourse($studentid){
- return $this->getEntityManager()
- ->createQuery(
- 'select * from AcmeDemoBundle: Course
- where startDate= :startDate or endDate= :endDate
- UPDATE AcmeDemoBundle:Course
- SET Course.payrollperiodid=Student.payrollperiodid
- FROM
- Student
- WHERE
- Course.startDate=Student.startDate or Course.endDate=Student.endDate'
- )
- ->setParameter()
- ->getResults();
- }
- public function createAction(Request $request)
- {
- $entity = new Student();
- $form = $this->createCreateForm($entity);
- $form->handleRequest($request);
- if ($form->isValid()) {
- $em = $this->getDoctrine()->getManager();
- $entity = $em->getRepository('AcmeDeomBundle:Student')->updateCourse();
- if (!$entity){
- $this->addFlash('error','ERROR! Student Record doesn't match Course Record');
- return $this->redirect($this->generateUrl('student_create'));
- }
- $em->persist($entity);
- $em->flush();
- return $this->redirect($this->generateUrl('student_show', array('studentid' => $entity->getstudentid())));
- }
- return array(
- 'entity' => $entity,
- 'form' => $form->createView(), );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement