I want to query my database tables for a user and return all information about that user. I have multiple tables, one for basic user information and other associated tables for things like emails, phone numbers, etc. because a user can have more than one of these.
If I query for a user that has multiple phone numbers, the query will join the phone numbers from the other table but it will return all of the user's data multiple times, once for each phone number like this:
Array( [name] => 'Bob Barker', [phone] => 'number-1')
Array( [name] => 'Bob Barker', [phone] => 'number-2')
instead of returning all of the user's data once with the phone numbers stored as an array in the returned data like this:
Array(
[name] => 'Bob Barker',
[phone] => Array(
[0] => 'number-1',
[1] => 'number-2',
)
)
Is it possible to make the query do this?
EDIT: My apologies for not having any table data, I'm asking because my database admin is out of office for a while and I'm trying to figure this out for him but I don't have access to our database.
group_concat()
you still need toexplode()
data string into desired array)