我有此查詢如何在PHP中創建這個數組?
select * from template_product where template_id = 8 group by class_id, product_id
從這個數據,我如何創建這樣
Array
(
[0] => Array
(
[step_number] => 1
[first_class] => [54, 56, 57, 58]
[second_class] => [54, 56, 57, 58, 59, 60, 63, 64, 52]
[third_class] => [54, 52]
)
[1] => Array
(
[step_number] => 2
[first_class] => [61]
[second_class] => [62]
[third_class] => [61]
)
)
基本上陣列返回
template_product_id template_step_id step_number product_id class_id template
16 11 1 54 1 8
17 11 1 56 1 8
18 11 1 57 1 8
19 11 1 58 1 8
20 11 1 54 2 8
21 11 1 56 2 8
22 11 1 57 2 8
23 11 1 58 2 8
24 11 1 59 2 8
25 11 1 60 2 8
26 11 1 63 2 8
27 11 1 64 2 8
28 11 1 52 2 8
29 11 1 54 3 8
30 11 1 52 3 8
31 12 2 61 1 8
32 12 2 62 2 8
33 12 2 61 3 8
,每一步數是一個新的數組並且class_id
是first_class
,second_class
,third_class based
關於它是否是1,2或3,最後各product_id
是在每個數組...
任何想法如何創建這個數組
再次感謝...這個工程真棒 – Trace 2011-04-21 18:17:48