Guest User

Untitled

a guest
Mar 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. public function OfferIndex(Request $request)
  2. {
  3.  
  4. $em = $this->getDoctrine()->getManager();
  5. $queryBuilder = $em->getRepository('BackBundle:offer')->createQueryBuilder('o');
  6. if (isset($_REQUEST['offerKey'])) {
  7. $queryBuilder
  8. ->where('CONCAT(o.name,o.technologies) LIKE :title')
  9. ->setParameter('title', '%' . $_REQUEST['offerKey'] . '%');
  10. }
  11. $query = $queryBuilder->getQuery();
  12.  
  13. $paginator = $this->get('knp_paginator');
  14. $pagination = $paginator->paginate(
  15. $query, /* query NOT result */
  16. $request->query->getInt('page', 1)/*page number*/,
  17. 2/*limit per page*/
  18. );
  19.  
  20. return $this->render('FrontBundle:pages:Offre d'emploi et de stage .html.twig',array(
  21. 'pagination' => $pagination
  22. ));
  23. }
  24.  
  25. <form method="post" id="filtres" action="{{ path('offer/list') }}">
  26. <div class="filter with-reset-search">
  27. <input type="text" placeholder="Mots clés" id="offerKey" name="offerKey"/>
  28. <span class="reset-search">
  29. <svg version="1.1" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"
  30. xmlns:xlink="http://www.w3.org/1999/xlink"><g id="icons" fill="#0064b9"><path
  31. d="M14.8,12l3.6-3.6c0.8-0.8,0.8-2,0-2.8c-0.8-0.8-2-0.8-2.8,0L12,9.2L8.4,5.6c-0.8-0.8-2-0.8-2.8,0 c-0.8,0.8-0.8,2,0,2.8L9.2,12l-3.6,3.6c-0.8,0.8-0.8,2,0,2.8C6,18.8,6.5,19,7,19s1-0.2,1.4-0.6l3.6-3.6l3.6,3.6 C16,18.8,16.5,19,17,19s1-0.2,1.4-0.6c0.8-0.8,0.8-2,0-2.8L14.8,12z"
  32. id="exit"></path></g></svg>
  33. </span>
  34. </div>
  35.  
  36. $queryBuilder
  37. ->where('CONCAT(o.name,o.technologies) LIKE :title')
  38. ->setParameter('title', '%' . $_REQUEST['offerKey'] . '%');
Add Comment
Please, Sign In to add comment