title: CakePHP 2.1 Select Distinct field but still select the ID in the SQL table
body: <p>Hi Im making a gallery on my news website for my portfolio having a minor glitch however. 
  I'm trying to select a distinct gallery so that it doesn't repeat itself, this is the code I have so far</p>
  
  <pre><code>function viewgalleries() {
  
      $viewgalleries = $this-&gt;Gallery-&gt;find('all', array(
          'fields' =&gt; 'DISTINCT Gallery.gallery_name'));
      if (!empty($this-&gt;request-&gt;params['requested'])) {
  return $viewgalleries; }
      $this-&gt;set('gallery', $viewgalleries); 
  
  }
  </code></pre>
  
  <p>and this is my view..</p>
  
  <pre><code>     &lt;?php $viewgalleries = $this-&gt;requestAction('/Galleries/viewgalleries');?&gt;
  
      &lt;div class="allgalleries"&gt;
  
   &lt;table class="galleries"&gt;
  &lt;?php foreach ($viewgalleries as $galleries): ?&gt;
      &lt;tr&gt;
         &lt;td&gt;
           &lt;span class="gallerylink"&gt;
              &lt;?php echo $this-&gt;Html-&gt;link($galleries['Gallery']['gallery_name'], 
                    array('controller' =&gt; 'Gallery', 'action' =&gt; 'view', 
                    $galleries['Gallery']['id'])); ?&gt;
           &lt;/span&gt;
         &lt;/td&gt;
      &lt;/tr&gt;
    &lt;?php endforeach; ?&gt;
    &lt;/table&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>This gives me want I want however it isn't selecting the id field in the table so its throwing me this error...</p>
  
  <pre><code>  Notice (8): Undefined index: id [APP/View/Galleries/viewgalleries.ctp, line 10]
  </code></pre>
  
  <p>Below it does show me the name of the gallery however
        Champions League Final 2012</p>
  
  <p>Any ideas as to how I could still select the id from the database??</p>
  
  <p>Thanks in advance or any help.</p>