Hello, I have a problem, this code below is returning a 'type' object, I need 'type' to be array.
while ($obj = $stmt->fetch(PDO::FETCH_ASSOC)) {
$stmt2 = $db->query('SELECT * FROM wines a, uva b WHERE a.id_tipo = '.$obj['idtipo'].' AND a.id_uva = b.id GROUP BY a.id_uva');
while ($obj2 = $stmt2->fetch(PDO::FETCH_ASSOC)) {
$wines[$obj['tipo']][] = $obj2;
}
}
It returns like this
{"ESPUMANTES": [
{
"id": "5",
"name": "MIOLO MILESSIME",
"uva": "BRUT"
},
],
"VINHOS BRANCOS": [
{
"id": "1",
"name": "CASA VALDUGA LEOPOLDINA GRAN RESERVA",
"uva": "CHARDONNAY"
},
]}
I need "SPARKLES" and "WHITE WINES" to be inside an array.
{
[
1: "ESPUMANTES" [
{
"id": "1",
"name": "CASA VALDUGA LEOPOLDINA GRAN RESERVA",
"uva": "CHARDONNAY"
}
]
],
[
2: "VINHOS BRANCOS" [
{
"id": "1",
"name": "CASA VALDUGA LEOPOLDINA GRAN RESERVA",
"uva": "CHARDONNAY"
}
]
}