I tried that @wgmv and I got some strange results:
{
"1": [
{
"location_id": 1,
"previous_location_id": 1,
"unit_id": 2,
"castle_id": 1,
"guild_id": null,
"unit_type_id": 3,
"current_health": 90,
"damage": 10,
"range": 3
}
],
"2": {
"1": {
"location_id": 2,
"previous_location_id": 2,
"unit_id": 3,
"castle_id": 2,
"guild_id": null,
"unit_type_id": 5,
"current_health": 100,
"damage": 20,
"range": 2
},
"6": {
"location_id": 2,
"previous_location_id": 5,
"unit_id": 7,
"castle_id": 5,
"guild_id": null,
"unit_type_id": 15,
"current_health": 180,
"damage": 20,
"range": 3
}
},
"3": {
"2": {
"location_id": 3,
"previous_location_id": 3,
"unit_id": 4,
"castle_id": 3,
"guild_id": null,
"unit_type_id": 1,
"current_health": 100,
"damage": 10,
"range": 1
},
"3": {
"location_id": 3,
"previous_location_id": 3,
"unit_id": 5,
"castle_id": 3,
"guild_id": null,
"unit_type_id": 1,
"current_health": 100,
"damage": 10,
"range": 1
}
},
"4": {
"5": {
"location_id": 4,
"previous_location_id": 4,
"unit_id": 8,
"castle_id": 4,
"guild_id": null,
"unit_type_id": 20,
"current_health": 300,
"damage": 40,
"range": 2
},
"7": {
"location_id": 4,
"previous_location_id": 1,
"unit_id": 1,
"castle_id": 1,
"guild_id": null,
"unit_type_id": 1,
"current_health": 100,
"damage": 10,
"range": 1
}
},
"5": {
"4": {
"location_id": 5,
"previous_location_id": 5,
"unit_id": 6,
"castle_id": 5,
"guild_id": null,
"unit_type_id": 15,
"current_health": 180,
"damage": 20,
"range": 3
}
}
}
I don't really understand why it's numerating castle_id like that...
It seems a bit closer to what I want, it's at least more organized. This is just some random test data that I'm using.
With this result I would only be interested in location_id 2 and 4, I want to ignore 1, 3, and 5.
I've been researching possible solutions nonstop and I'm now wondering if I need some sort of raw SQL SELECT that will give more control.