title: CakePHP array structure from a HABTM query
body: <p>I have two tables linked via a HABTM. countries &amp; networks. They are linked together by the countries_networks lookup table.</p>
  
  <p>I need to get all of the countries and all of the associated network ids for each corresponding country. I don't need to go as far as getting the network names, simply getting the ids from the lookup table will suffice.</p>
  
  <p>If I do a find(all) it gives me an array of countries but not in the structure that I need. I need to return something link this, <strong>but I only need Country.countryName and CountriesNetwork.network_id</strong>:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [Country] =&gt; Array
                  (
                      [countryName] =&gt; Aeroplane
                  )
              [Network] =&gt; Array
                  (
                      [0] =&gt; Array
                          (
                              [id] =&gt; 1
                              [CountriesNetwork] =&gt; Array
                                  (
                                      [id] =&gt; 1
                                      [country_id] =&gt; 1
                                      [network_id] =&gt; 1
                                  )
                          )
  
                      [1] =&gt; Array
                          (
                              [id] =&gt; 7
                              [CountriesNetwork] =&gt; Array
                                  (
                                      [id] =&gt; 2
                                      [country_id] =&gt; 1
                                      [network_id] =&gt; 7
                                  )
                          )
                  )
          )
  )
  </code></pre>
  
  <p>Is there a way of doing this with a findall()? as if I pass fields as an array I always seem to get an unknown column names SQL error.
  Or even a custom query? Many thanks in advance to anyone who may be able to help.</p>