I have an table like this:
id //not index | origin |
---|---|
1 | germany |
1 | usa |
2 | usa |
2 |
I want to get every Entity witch has an origin (!= ”) but in a multidimensional Array, sorted by the id, looking like this:
[
[
{
'id': '1',
'origin': 'germany'
},
{
'id': '1',
'origin': 'usa'
},
],
[
{
'id': '2',
'origin': 'usa'
}
]
]
is this even possible with a query or do I have to do this in PHP?
3
Answers
After looking at all the answers I did it like so:
You can remove the empty fields like this for e.x.
Result:
You can use QueryBuilder in your repository to do that.
In your Controller :
Regards,