title: PDO fetchAll() primary key as array group key
body: <p>I want to store the contents of a specific database into an array, grouped by their primary keys. (Instead of the useless way PDO fetchAll() organises them).</p>
  
  <p>My current code:</p>
  
  <pre><code>$DownloadsPDO = $database-&gt;dbh-&gt;prepare("SELECT * FROM `downloads`");
  $DownloadsArray =  $DownloadsPDO-&gt;execute();
  $DownloadsArray =  $DownloadsPDO-&gt;fetchAll();
  </code></pre>
  
  <p>Which then outputs:</p>
  
  <pre><code>Array ( [0] =&gt; Array ( [id] =&gt; 0 [0] =&gt; 0 [path] =&gt; /xx-xx/testfile.zip [1] =&gt; /xx-xx/testfile.zip [name] =&gt; Test Script [2] =&gt; Test Script [status] =&gt; 1 [3] =&gt; 1 ) [1] =&gt; Array ( [id] =&gt; 1 [0] =&gt; 1 [path] =&gt; /xx-xx/test--file.zip [1] =&gt; /xxxx/testfile.zip [name] =&gt; New Script-UPDATE [2] =&gt; New Script-UPDATE [status] =&gt; 1 [3] =&gt; 1 ) )
  </code></pre>
  
  <p>I was considering to use <code>PDO::FETCH_PAIR</code>, however I will be very soon expanding the amount of data I want to be able to use on this script. This works currently, but when I start to expand the amount of downloads and more clients come into play, obviously the way the data is grouped causes an issue. </p>
  
  <p>Is it possible for me to group each array by their primary key (which is id)?</p>