I want to use a column with numbers as array key.
I use a loop after fetchAll but I would like to know if is it possible to make it direclty.
My query:
$RequeteSql = $db->query("
SELECT *
FROM PouvoirsNumeros
LEFT JOIN Pouvoirs ON (Pouvoirs.Pouvoir_Id = PouvoirsNumeros.Pouvoir_Id)
WHERE
PouvoirsNumeros.TypePerso = 'Ange'
ORDER BY
Pouvoirs.Pouvoir_Nom");
$ResultatRequete = $RequeteSql->fetchAll(PDO::FETCH_GROUP|PDO::FETCH_ASSOC);
With it, I have:
(
[0] => Array
(
[TypePerso] => Ange
[Numero_Des] => 711
[Pouvoir_Id] => 157
...
)
...
)
I would like to replace the key with Pouvoir_Id:
(
[157] => Array
(
[TypePerso] => Ange
[Numero_Des] => 711
[Pouvoir_Id] => 157
...
)
...
)
With PDO::FETCH_GROUP|PDO::FETCH_ASSOC:
(
[157] => Array
(
[0] => Array
(
[TypePerso] => Ange
[Numero_Des] => 711
[Pouvoir_Id] => 157
...
)
)
...
)
Is it possible to make it directly with PDO ?