私はこのLeague_tableを持っています:
+--------+----------+-------------+
| id | star | section |
+--------+----------+-------------+
| 1 | 1 | A |
| 2 | 0 | A |
| 3 | 1 | B |
| 4 | 1 | B |
| 5 | 0 | C |
| 6 | 1 | C |
| 7 | 0 | D |
| 8 | 1 | D |
+--------+----------+-------------+
可能かどうか迷っているのですが、まとめて返却してもらうことはできますか?
この単純なクエリSELECT id, star FROM league_table WHERE star = 1"
を実行してから使用するとしますPDO FETCH ALL
私はこの出力を持つことができます:
Array
(
[0] => Array
(
[id] => 1
[star] => 1
)
[1] => Array
(
[id] => 3
[star] => 1
)
[2] => Array
(
[id] => 4
[star] => 1
)
[3] => Array
(
[id] => 6
[star] => 1
)
[4] => Array
(
[id] => 8
[star] => 1
)
)
ただし、この出力をより整理できるようにすることはできますか?
Array
(
[A] => Array
(
[0] => Array
(
[id] => 1
[star] => 1
)
)
[B] => Array
(
[0] => Array
(
[id] => 3
[star] => 1
)
[1] => Array
(
[id] => 4
[star] => 1
)
[C] => Array
(
[0] => Array
(
[id] => 6
[star] => 1
)
)
[D] => Array
(
[0] => Array
(
[id] => 8
[star] => 1
)
)
)