title: cakephp 3 using contain in a sub associated table
body: <p>I have 4 tables, Proposals, Bids, Users and Drivers. Proposals has Many bids and Bids has many Users and finally Drivers belong to Users.</p>
  
  <p>What I'm trying to do is get all bids for proposal 1 which should show Proposal Name, Bid number, User details who bid including the fields in driver table which hold some specific details of the user.</p>
  
  <p>My schema is as below:</p>
  
  <pre><code>    CREATE TABLE `proposals` (
        `id` int(11) NOT NULL,
        `email` varchar(200) NOT NULL,
        `item` int(11) NOT NULL,
        `desc` varchar(100) NOT NULL,
        `sess` varchar(255) NOT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
      CREATE TABLE `bids` (
        `id` int(11) NOT NULL,
        `proposal_id` int(11) NOT NULL,
        `user_id` int(11) NOT NULL,
        `amount` double NOT NULL,
        `session_code` varchar(255) NOT NULL
      ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  
      CREATE TABLE `users` (
        `id` int(11) NOT NULL,
        `First_Name` varchar(200) DEFAULT NULL,
        `Last_Name` varchar(200) DEFAULT NULL,
        `role` varchar(200) NOT NULL,
        `Mobile_No` int(11) DEFAULT NULL,
        `Membership_Start` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
        `Address` varchar(255) DEFAULT NULL,
        `Post_Code` varchar(255) DEFAULT NULL,
        `email` varchar(50) DEFAULT NULL,  
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
      CREATE TABLE `drivers` (
        `id` int(11) NOT NULL,
        `user_id` int(11) NOT NULL,
        `verified` varchar(255) NOT NULL,
        `dealno` varchar(255) NOT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  </code></pre>
  
  <p>And here is the code I'm using which is failing - I know I have got it wrong:</p>
  
  <pre><code>     $query = $this-&gt;Bids-&gt;find()    
          -&gt;contain([
              "Users",
              "Drivers",
              "Proposals"
  
          ])
          -&gt;matching("Proposals", function($q){
              return $q-&gt;where(["proposals.id" =&gt; $id ]);
          });
  
          $bid = $this-&gt;paginate($query);
  </code></pre>
  
  <p>Any help would be highly appreciated.</p>