QUR_SEL($sql); if(!$rez['err']&&$rez['kol']){ $filer = $rez['rez'][0]; $id_file = $filer['id']; $pi = pathinfo($filer['file']); $file_comp = $pi['dirname'] . '/' . $pi['filename'] . '_comp.json'; $array = json_decode(file_get_contents($file_comp),1); foreach ($array as $index => $val) { if(isset($val['discips'])){ $rez1 = $DB->QUR_SEL('SELECT id FROM acs_fshp_compet WHERE id_file='.$id_file.' AND `index`="'.$index.'"'); if(!$rez1['err']&&$rez1['kol']) { $id_compet = $rez1['rez'][0]['id']; foreach ($val['discips'] as $key => $discip) { $rez1 = $DB->QUR_SEL('SELECT id,index1,name FROM acs_fshp_uchebplans WHERE id_file='.$id_file.' AND `index1`="'.trim($discip['shifr']).'"'); if(!$rez1['err']&&$rez1['kol']) { $id_uchebplan = $rez1['rez'][0]['id']; $name = $rez1['rez'][0]['index1'].' '.$rez1['rez'][0]['name']; $rez1 = $DB->QUR_SEL('SELECT id FROM acs_fshp_uchebplans_compet WHERE id_uchebplans='.$id_uchebplan.' AND id_compet='.$id_compet); if(!$rez1['err']&&$rez1['kol']) { $id_uchebplan_compet = $rez1['rez'][0]['id']; //echo $id_file.':'.$id_compet.' :'.$id_uchebplan.'='.$id_uchebplan_compet.' есть связь
'; }else{ echo $id_file.':'.$id_compet.' :'.$id_uchebplan.' ['.$name.'] нет связи'; if($do_it) { $rez1 = $DB->QUR('INSERT INTO acs_fshp_uchebplans_compet VALUES (0,' . $id_uchebplan . ',' . $id_compet . ')'); if (!$rez1['err']) echo ' - добавили'; else echo ' - не добавили'; } echo '
'; } } } } } } //echo '
'.print_r($array,1).'
'; } /* SELECT * FROM `acs_fshp_compet` WHERE `id_file`=113 AND `index`="УК-1.1" fshp_compet id 18620 45926 50858 SELECT * FROM `acs_fshp_uchebplans` WHERE `id_file`=113 AND `name` LIKE "%Ознакомит%" shp_uchebplans id 18601 index1 Б2.О.01(У) SELECT * FROM `acs_fshp_uchebplans_compet` WHERE `id_uchebplans`=18601 * */