title: How to put pagination on search result using symfony2?
body: <p>I am working on a project using symfony2. I already have my search function and it is already working. But what I want is to have pagination on the search results since there are times that there are a lots of data being retrieve. How can I possibly do it?</p>
  
  <p>Here is my code :</p>
  
  <pre><code>public function searchAction (Request $request) {
  
          $request = $this-&gt;getRequest();
          $data = $request-&gt;get('search');
  
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $query = $em-&gt;createQuery (
              'SELECT a,b,c FROM SampleBundle:transactDetail a
              JOIN a.transact b
              JOIN b.transactType c
              WHERE b.pNumber LIKE :data
              OR b.senderId LIKE :data'
          )
          -&gt;setParameter('data', "%$data%");
          $result = $query-&gt;getResult();
  
          if ($result == null ) {
              return $this-&gt;render('SampleBundle:Sample:noresult.html.twig');
          }
          return $this-&gt;render('SampleBundle:Sample:search.html.twig', array('result' =&gt; $result));
      }
  </code></pre>
  
  <p>Thanks in advance.</p>