title: Query Request Data Prob
body: <p>I am new to Cakephp 3.0 and i don't know how to get all the products of the contracts in my example.</p>
  
  <p><a href="http://hpics.li/d2568a6" rel="nofollow">http://hpics.li/d2568a6</a></p>
  
  <p>Models :</p>
  
  <p><strong><em>SalesContracts:</em></strong></p>
  
  <pre><code>&lt;?php
  
  namespace App\Model\Table;
  
  use Cake\ORM\Table;
  
  class SalesContractsTable extends Table
  {
  
      public function initialize(array $config)
      {
          $this-&gt;addBehavior('Timestamp');
          $this-&gt;table('sales_contracts');
  
          $this-&gt;belongsToMany('SalesProducts',[
              'className' =&gt; 'SalesProducts',
              'type' =&gt; 'INNER',
              'joinTable' =&gt; 'sales_contracts_products',
              'foreignKey' =&gt; 'sales_contracts_id',
              'targetForeignKey' =&gt; 'sales_products_id'
          ]);
      }
  }
  </code></pre>
  
  <p><strong><em>SalesProducts:</em></strong></p>
  
  <pre><code>&lt;?php
  
  namespace App\Model\Table;
  
  use Cake\ORM\Table;
  
  class SalesProductsTable extends Table
  {
  
      public function initialize(array $config)
      {
          $this-&gt;addBehavior('Timestamp');
          $this-&gt;table('sales_products');
  
          $this-&gt;belongsToMany('SalesContracts',[
              'className' =&gt; 'SalesContracts',
              'joinTable' =&gt; 'sales_contracts_products',
              'type' =&gt; 'INNER',
              'foreignKey' =&gt; 'sales_products_id',
              'targetForeignKey' =&gt; 'sales_contracts_id'
          ]);
      }
  }
  </code></pre>
  
  <p>This method receives the ID of the contract in parameter and I need to use it to get his products.</p>
  
  <pre><code>    public function show_products($id = null){
   $products $this-&gt;SalesContracts-&gt;find('all')-&gt;contain(['SalesProducts'])-&gt;where(['SalesContractsProducts.sales_contracts_id' =&gt; $id]);
  
      }
  </code></pre>
  
  <p>But I cannot write a proper query about that..</p>
  
  <p>Any solutions ?</p>
  
  <p>Thanks for your help!</p>