title: Check if an array contains any element of another array in doctrine query builder
body: <p>I would like to know if it's possible to check if an array contains any element of another array in doctrine query builder.</p>
  
  <p>In my case, i want to get all the products (items) who have at least one of the category in the array passed in parameter.</p>
  
  <blockquote>
    <p>Relationship between Item and Category :</p>
  </blockquote>
  
  <pre><code>/**
   *  @ORM\ManyToMany(targetEntity="Category")
   *  @ORM\JoinTable(name="items_categories",
   *      joinColumns={@ORM\JoinColumn(name="item_id", referencedColumnName="id", nullable=false)},
   *      inverseJoinColumns={@ORM\JoinColumn(name="category_id", referencedColumnName="id", nullable=false)}
   *      )
   */
  private $categories;
  </code></pre>
  
  <blockquote>
    <p>My first try from the Item repository (i know this work if i have only
    one value to check):</p>
  </blockquote>
  
  <pre><code>public function getListItemsFromCatList($listCat) {
      $qb = $this-&gt;createQueryBuilder('i');
  
      $qb-&gt;select('i')
              -&gt;where($qb-&gt;expr()-&gt;like('i.categories', ':listCat'))
              -&gt;setParameter('listCat', '%"' . $listCat . '"%');
  
      return $qb-&gt;getQuery()-&gt;getResult();
  }
  </code></pre>
  
  <p><strong>$listCat is an array of Category Entity :</strong></p>
  
  <pre><code>array (size=5)
    0 =&gt; 
      object(ItemBundle\Entity\Category)[518]
        private 'id' =&gt; int 22
        private 'children' =&gt; 
          object(Doctrine\ORM\PersistentCollection)[520]
            private 'snapshot' =&gt; 
              array (size=2)
                ...
            private 'owner' =&gt; 
              &amp;object(ItemBundle\Entity\Category)[518]
            private 'association' =&gt; 
              array (size=15)
                ...
            private 'em' =&gt; 
              object(Doctrine\ORM\EntityManager)[796]
                ...
            private 'backRefFieldName' =&gt; string 'parent' (length=6)
            private 'typeClass' =&gt; 
              object(Doctrine\ORM\Mapping\ClassMetadata)[579]
                ...
            private 'isDirty' =&gt; boolean false
            protected 'collection' =&gt; 
              object(Doctrine\Common\Collections\ArrayCollection)[515]
                ...
            protected 'initialized' =&gt; boolean true
        private 'parent' =&gt; null
        private 'name' =&gt; string 'Luxe' (length=4)
    1 =&gt; 
      object(ItemBundle\Entity\Category)[504]
        private 'id' =&gt; int 25
        private 'children' =&gt; 
          object(Doctrine\ORM\PersistentCollection)[505]
            private 'snapshot' =&gt; 
              array (size=0)
                ...
            private 'owner' =&gt; 
              &amp;object(ItemBundle\Entity\Category)[504]
            private 'association' =&gt; 
              array (size=15)
                ...
            private 'em' =&gt; 
              object(Doctrine\ORM\EntityManager)[796]
                ...
            private 'backRefFieldName' =&gt; string 'parent' (length=6)
            private 'typeClass' =&gt; 
              object(Doctrine\ORM\Mapping\ClassMetadata)[579]
                ...
            private 'isDirty' =&gt; boolean false
            protected 'collection' =&gt; 
              object(Doctrine\Common\Collections\ArrayCollection)[500]
                ...
            protected 'initialized' =&gt; boolean false
        private 'parent' =&gt; 
          object(ItemBundle\Entity\Category)[512]
            private 'id' =&gt; int 23
            private 'children' =&gt; 
              object(Doctrine\ORM\PersistentCollection)[513]
                ...
            private 'parent' =&gt; 
              object(ItemBundle\Entity\Category)[518]
                ...
            private 'name' =&gt; string 'Bijoux' (length=6)
        private 'name' =&gt; string 'Bagues' (length=6)
  </code></pre>