Cakephp 3: belongsToMany contain or matching condition?
<p>Piece of my database looks like <a href="http://i.stack.imgur.com/4eMdI.jpg" rel="nofollow">database part</a></p>

<p>Categories use tree behavior.</p>

<p>How can i get a manufacturer's (Producers) Products for current Category? 
I tried contain and matching, but i received duplicated data or Producers names without related Products.</p>

<p>EDIT:</p>

<pre><code>$query = $this-&gt;Producers-&gt;find()-&gt;matching('Products.Categories',
    function ($q) {
        return $q-&gt;where(['Categories.id' =&gt; 18]); 
    }
);
</code></pre>

<p>Results:</p>

<pre><code>Producent: Canon
-------------------------------------------
| ID | Name        | Barcode              |
-------------------------------------------
| 1  | EOS 1000D   |                      |
-------------------------------------------
| 18 | Camera      |                      |
-------------------------------------------
| 23 | 18          |                      |
-------------------------------------------
</code></pre>

<p>First row (id = 1) it's what i need.
Now i have to remove from results:
second row (id = 18) this is Category id from table Categories, 
thrid row (id = 23) - from Products_Categories table. </p>