Q:

PDO fetch object key value as id and keep the id in the object

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.
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.
I tried this myself
$getUsers->fetchAll(\PDO::FETCH_UNIQUE|\PDO::FETCH_CLASS, User\Basic::class);

This does return the id, but the id is everywhere 0.
concept:
{
   id: 3,
   name: 'pietje'
},
{
   id: 4,
   name: 'pietje'
}

Then i want a array of object like this (I think I made a mistake here)
[3 => {
       id: 3,
       name: 'pietje'
     }, 
 4=> {
       id: 4,
       name: 'pietje'

}]

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.
Any one?

A:

Just select your field twice, 
SELECT id, table.* FROM table ...

