title: PDO fetch object key value as id and keep the id in the object
body: <p>I have looked around alot with this problem. I want to get a array of my objects and the id should be the key value. I did this using the PDO::FETCH_UNIQUE.</p>
  
  <p>It almost worked the way I want to. Problem here is that the ID will be removed from the object and will only show as the key value. But I want the key value as the id value AND KEEP the id attached to the object.</p>
  
  <p>I tried this myself</p>
  
  <pre><code>$getUsers-&gt;fetchAll(\PDO::FETCH_UNIQUE|\PDO::FETCH_CLASS, User\Basic::class);
  </code></pre>
  
  <p>This does return the id, but the id is everywhere 0.</p>
  
  <p>concept:</p>
  
  <pre><code>{
     id: 3,
     name: 'pietje'
  },
  {
     id: 4,
     name: 'pietje'
  }
  </code></pre>
  
  <p>Then i want a array of object like this (I think I made a mistake here)</p>
  
  <pre><code>[3 =&gt; {
         id: 3,
         name: 'pietje'
       }, 
   4=&gt; {
         id: 4,
         name: 'pietje'
  
  }]
  </code></pre>
  
  <p>But like i sayed, the id in the object is always 0the way I did it, and i could not find anything on the internet about the way I want it. Yhea sure I can loop every user and add a id, but then I can just loop through every user and create a new array with the user id as key value.</p>
  
  <p>Any one?</p>