将以下数据放在一个表格中:
programgroup,programcode
"C1","AM"
"C1","CC"
"C1","CC"
"C1","CC"
"C1","CC"
"C1","CC"
"C1","CC"
"C1","CP"
"C1","CP"
"C1","CP"
"C1","CP"
"C1","PL"
"C1","PL"
"C1","PL"
"C1","PL"
"C1","PL"
"C4","2IC"
"C4","2IC"
"C4","2IC"
"C4","2IC"
"C4","2IC"
"C4","AO"
"C4","AO"
"C4","AO"
"C4","IP"
"C4","IP"
"C4","PA"
"C4","PA"
"C4","PM"
"C4","PR"
"C4","PR"
"C4","SR"
"C4","WH3"
我正在读取数据并遍历记录,我需要在表中为每个 ProgramGroup 插入一个类别,并为每个 ProgramCode 插入一个子类别,每个 ProgramCode 具有它所包含的 ProgramGroup 的类别的 parent_id,即(MAIN 类别将已经存在)
category_id, value, parent_id
0, "MAIN", null
1, "C1", 0
2, "AM", 1
3, "CC", 1
4, "CP", 1
5, "PL", 1
6, "C4", 0
7, "21C", 6
8, "AO", 6
9, "IP", 6
10, "PA", 6
11, "PM", 6
12, "PR", 6
13, "SR", 6
14, "WH3", 6
谁能告诉我如何在 PHP 伪代码中做到这一点?