title: 'Invalid parameter number: number of bound variables does not match number of tokens' Symfony
body: <p>I'm working on a <strong>symfony project entity with query builder</strong>. When I try to run this function I get this issue.</p>
  
  <blockquote>
    <p>Invalid parameter number: number of bound variables does not match number of tokens</p>
  </blockquote>
  
  <pre><code>public function json_filterAllproductsAction() {
  
      $search = "";
      $category = 1;
  
      //Combine tables and create the query with querybuilder
      $em = $this-&gt;container-&gt;get('doctrine.orm.entity_manager');
  
      $qb = $em-&gt;createQueryBuilder();
  
      $qb-&gt;select('p')
              -&gt;from('EagleAdminBundle:Products', 'p')
              -&gt;orderBy('p.id', 'DESC');
      if ($category != 0) {
          $qb-&gt;where($qb-&gt;expr()-&gt;in('p.category', '?1'))
                  -&gt;setParameter(1, $category);
      }
      $qb-&gt;where('p.productTitle LIKE :title')
              -&gt;setParameter('title', "$search%");
  
      //convert to json using "JMSSerializerBundle"
      $serializer = $this-&gt;container-&gt;get('serializer');
      $jsonproducts = $serializer-&gt;serialize($qb-&gt;getQuery()-&gt;getResult(), 'json');
      return new Response($jsonproducts);
  }
  </code></pre>
  
  <p>I think error is in </p>
  
  <blockquote>
    <p>$qb->where($qb->expr()->in('p.category', '?1'))
                    ->setParameter(1, $category);</p>
  </blockquote>
  
  <p>It would be great help someone can help me. </p>