我正在尝试连接表以防止过多的数据库查询,但我不喜欢数据返回的方式。
查询:
SELECT person.name, dog.dog_name FROM person JOIN dog ON person.id = dog.person_id
返回看起来像这样:
Array
(
[0] => Array
(
[name] => Jim
[dog_name] => Wolf
)
[1] => Array
(
[name] => Jim
[dog_name] => Frisky
)
[2] => Array
(
[name] => Tina
[dog_name] => Pokedot
)
[3] => Array
(
[name] => Tina
[dog_name] => Spiky
)
)
是否可以让查询返回如下内容:
Array
(
[0] => Array
(
[name] => Jim
[dog_name] => array(Wolf, Frisky)
)
[1] => Array
(
[name] => Tina
[dog_name] => array(Pokedot, Spiky)
)
)