/**
  *@Route("/search/", name="search")
  */
 public function indexAction(Request $request)
 {
     if ($request->getMEthod() == 'POST') {
         $title = $request->get('search');
         //echo "<div class=\"searchText\">Search Results</div><hr/>";
         $connect = $this->get('database_connection');
         $search1['result'] = $connect->fetchAll("select DISTINCT Nm From companies");
         $Search_terms = explode(' ', $title);
         //splits search terms at spaces
         $query = "SELECT * FROM companies WHERE ";
         $query1 = "SELECT * FROM items WHERE ";
         $str = mysql_real_escape_string($title);
         $query .= " Nm LIKE '%{$str}%' ";
         $query1 .= " Nm LIKE '%{$str}%' ";
         $searsh['result'] = $connect->fetchAll($query);
         $search['result'] = $connect->fetchAll($query1);
         $menuRepository = $this->getDoctrine()->getManager()->getRepository('AppBundle:Menu');
         $menu['result'] = $menuRepository->showAction();
         $data = ['search1' => $search1['result'], 'menu' => $menu['result'], 'shearch' => $searsh['result'], 'search' => $search['result']];
         return $this->render('AppBundle:Default:index2.html.twig', compact('data'));
     }
 }
Пример #2
0
 /**
  *@Route("/search/", name="search")
  */
 public function indexAction(Request $request)
 {
     if ($request->getMEthod() == 'POST') {
         $title = $request->get('search');
         //echo "<div class=\"searchText\">Search Results</div><hr/>";
         $connect = $this->get('database_connection');
         //$search1['result'] = $connect->fetchAll("select DISTINCT Nm From companies");
         $stmt = $this->getDoctrine()->getManager()->getConnection()->prepare("select DISTINCT Nm From companies");
         $stmt->execute();
         $search1['result'] = $stmt->fetchAll();
         $Search_terms = explode(' ', $title);
         //splits search terms at spaces
         $searchCondition = '';
         ////
         foreach ($Search_terms as $i => $term) {
             if ($i != 0) {
                 $searchCondition .= ' OR ';
             }
             $searchCondition .= ' Nm LIKE :term' . $i . ' ';
         }
         $query = $this->getDoctrine()->getManager()->getConnection()->prepare("SELECT * FROM companies WHERE " . $searchCondition);
         foreach ($Search_terms as $i => $term) {
             $query->bindValue(':term' . $i, $term);
         }
         $search['result'] = $query->fetchAll();
         $query->execute();
         $query1 = $this->getDoctrine()->getManager()->getConnection()->prepare("SELECT * FROM items WHERE Nm LIKE :title");
         $query1->bindValue(':title', $title);
         $query1->execute();
         $search1['result'] = $query1->fetchAll();
         $menuRepository = $this->getDoctrine()->getManager()->getRepository('AppBundle:Menu');
         $menu['result'] = $menuRepository->showAction();
         $data = ['search1' => $search1['result'], 'menu' => $menu['result'], 'shearch' => $search['result'], 'search' => $search1['result']];
         return $this->render('AppBundle:Default:index2.html.twig', compact('data'));
     }
 }
Пример #3
0
 /**
  *@Security("has_role('ROLE_REDACTEUR')")
  */
 public function editAction(Equipe $equipe, Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $equipe = $em->getRepository("MdyGstBundle:Equipe")->find($equipe->getId());
     if ($equipe == null) {
         throw new NotFoundException('L\'équipe recherchée ["' . $equipe->getId() . '"] n\'a pas été trouvée');
     }
     $form = $this->createForm(new EquipeType(), $equipe);
     if ($request->getMEthod() === "POST") {
         $form->bind($request);
         if ($form->isValid()) {
             $em->persist($equipe);
             $em->flush();
             return $this->redirect($this->generateUrl('mdy_gst_listEquipe'));
         }
     }
     return $this->render('MdyGstBundle:Gst:Equipe/edit.html.twig', array('form' => $form->createView()));
 }