query("truncate table Rozdzielcza_test_bzyk_Cables_to_PE"); //unset($ID_Way); /*foreach($cables_from_joins_to_PE_arr as $id_j=>$Path_Point_val) { $sql_Path_Point_val="insert into Rozdzielcza_test_bzyk_Cables_to_PE (the_geom,ID_Way,ID_Point,len,PE_ID_Join) values (ST_GeomFromText('".$Path_Point_val['LINESTRING']."'),'".$Path_Point_val['ID_Way']."', '".$Path_Point_val['ID_Point']."' ,'".$Path_Point_val['len']."','".$Path_Point_val['PE_ID_Join']."' ) "; echo "#216Query path ins:: ".$sql_Path_Point_val." "; //if(strlen($edge_joins_filled_paths[$ID_Way]['asText'])>2) if(strlen($Path_Point_val['LINESTRING'])>1) DB::getPDO()->query($sql_Path_Point_val); else echo " ERROR blad danych!!! dla ID_Point:".$Path_Point_val['ID_Point']; //else echo "#296 path nie wygenerowalo sie !! dla ".$ID_Way." i pkt ".$pkt_A." , ".$pkt_B." \n"; } */ $tables['Y']['BI_audit_ENERGA_PRACOWNICY']['rel']['pesel']='pesel'; $tables['Y']['BI_audit_ENERGA_PRACOWNICY']['rel']['nip']='nip'; $tables['Y']['BI_audit_ENERGA_PRACOWNICY']['rel']['regon']='regon'; $tables['X']['BI_audit_KW_requested']['rel_search']['pesel']='Seller_Person'; $tables['X']['BI_audit_KW_requested']['rel']['pesel']['search']='like'; $tables['X']['BI_audit_ENERGA_RUM_KONTRAHENCI']['rel']['nip']='NIP'; $tables['X']['BI_audit_ENERGA_RUM_KONTRAHENCI']['rel']['regon']='REGON'; $tables['X']['BI_audit_ENERGA_RUM_KONTRAHENCI']['rel']['pesel']='PESEL'; $tables['X']['BI_audit_ENERGA_RUM_KONTRAHENCI']['rel']['teryt']=1; $tables['Z']['BI_audit_CEIDG']['rel']['nip']='nip'; $tables['Z']['BI_audit_CEIDG']['rel']['regon']='regon'; $tables['Z']['BI_audit_CEIDG']['ref'][]='BI_audit_CEIDG_pelnomocnicy'; $tables['Z']['BI_audit_CEIDG']['ref'][]='BI_audit_CEIDG_powiazania'; $tables['Z']['BI_audit_CEIDG_pelnomocnicy']['rel']['nip']='nip'; $tables['Z']['BI_audit_CEIDG_pelnomocnicy']['rel_and']['adres']['miejscowosc']='miejscowosc'; $tables['Z']['BI_audit_CEIDG_pelnomocnicy']['rel_and']['adres']['ulica']='ulica'; $tables['Z']['BI_audit_CEIDG_pelnomocnicy']['rel_and']['adres']['kodPocztowy']='kodPocztowy'; //$tables['Z']['BI_audit_CEIDG_pelnomocnicy']['ref'][]='BI_audit_CEIDG'; $tables['Z']['BI_audit_CEIDG_powiazania']['rel']['nip']='nip'; $tables['Z']['BI_audit_CEIDG_powiazania']['rel']['regon']='nip'; //$tables['Z']['BI_audit_CEIDG_powiazania']['ref'][]='BI_audit_CEIDG'; $tables['Z']['BI_audit_KRS']['rel']['nip']='nip'; $tables['Z']['BI_audit_KRS']['rel']['regon']='regon'; $tables['Z']['BI_audit_KRS']['rel']['krs']='krs'; $tables['Z']['BI_audit_KRS']['rel_and']['adres']['miejscowosc']='A_miejscowosc'; $tables['Z']['BI_audit_KRS']['rel_and']['adres']['ulica']='A_ulica'; $tables['Z']['BI_audit_KRS']['rel_and']['adres']['kodPocztowy']='A_kod'; $tables['Z']['BI_audit_KRS']['ref'][]='BI_audit_KRS_person'; $tables['Z']['BI_audit_KRS']['ref'][]='BI_audit_KRS_company'; $tables['Z']['BI_audit_KRS_company']['rel']['regon']='regon'; $tables['Z']['BI_audit_KRS_company']['rel']['krs']='krs'; function start_dig($tables) { global $db; foreach($tables['Y'] as $Y=>$t) { $sql='select * from '.$Y ; $res=$db->query($sql); while($h=$db->fetch($res)) { $hist_loop[$Y][]=$h; dig_next($hist_loop,$t,$h); } } } function dig_next($hist_loop,$prev_tbl,$prev_dig) { global $db,$tables; //detect next ref tbls $sql = array(); foreach($tables['Z'] as $Z=>$z) { //rels in tbls foreach($z['rel'] as $z_rel_from=>$z_rel_to) { echo "test z_rel_fr ".$z_rel_from." to z_rel_to ".$z_rel_to ; if( $prev_tbl['rel'][$z_rel_from] ) { $sql[$Z]['rel'][$z_rel_to]= $prev_dig[$prev_tbl['rel'][$z_rel_to]]; } /*foreach($prev_dig as $col=>$val) { //transl ref to ref if( $prev_tbl['rel'][$z_rel_from] ) { $sql[$Z]['rel'][$z_rel_to]=$val; } } */ } } print_r($sql); } start_dig($tables);