|
|
@@ -154,6 +154,8 @@ function dig_next($hist_loop,$prev_tbl,$prev_dig,$loop,$hist_time,$last_tbl='n/s
|
|
|
//detect next ref tbls
|
|
|
$sql = array();
|
|
|
$sql_RELAND = array();
|
|
|
+
|
|
|
+
|
|
|
foreach($tables['Z'] as $Z=>$z) {
|
|
|
//rels in tbls
|
|
|
foreach($z['rel'] as $z_rel_from=>$z_rel_to) {
|
|
|
@@ -161,6 +163,7 @@ function dig_next($hist_loop,$prev_tbl,$prev_dig,$loop,$hist_time,$last_tbl='n/s
|
|
|
if( isset($prev_tbl['rel'][$z_rel_from])) {
|
|
|
if( strlen($prev_dig->$prev_tbl['rel'][$z_rel_from]) > 0 ) {
|
|
|
$sql[$Z]['rel'][$z_rel_to] = $prev_dig->$prev_tbl['rel'][$z_rel_from];
|
|
|
+ $path_rel[$Z][]="(".$z_rel_to.")";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -182,11 +185,12 @@ function dig_next($hist_loop,$prev_tbl,$prev_dig,$loop,$hist_time,$last_tbl='n/s
|
|
|
}
|
|
|
|
|
|
if($rel_and_ok==2) {
|
|
|
+ $path_rel_and = array();
|
|
|
// echo "\n<br>#133 Z=".$Z." ok rel_and_ok=".$rel_and_ok;
|
|
|
foreach($z_rel_and_name as $z_rel_and_name_cur=>$z_rel_and_name_col_to) {
|
|
|
// echo "\n<br> 135... ok. Z=".$Z."/ z_rel_and_name=".$z_rel_and_name_cur."/ z_rel_and_name_col_to=".$z_rel_and_name_col_to."/ prev_dig-z_rel_and_name_cur=".$prev_dig->$z_rel_and_name_cur;
|
|
|
$sql_rel_and[$Z][$z_rel_and][$z_rel_and_name_col_to]=$prev_dig->$z_rel_and_name_col_to;
|
|
|
-
|
|
|
+ $path_rel_and[]="(".$z_rel_and_name_col_to.")";
|
|
|
}
|
|
|
} else {
|
|
|
// echo "<br>#137 error rel_and_ok=".$rel_and_ok;
|
|
|
@@ -375,6 +379,7 @@ function dig_next($hist_loop,$prev_tbl,$prev_dig,$loop,$hist_time,$last_tbl='n/s
|
|
|
*/
|
|
|
if( isset($sql_t)) {
|
|
|
foreach($sql_t as $T => $sql_ext) {
|
|
|
+ $path.=$path_rel[$T][ key() ];
|
|
|
dig_arr_cur($hist_loop,$T,$sql_ext,$hist_time,$loop,$last_tbl,$path);
|
|
|
}
|
|
|
}
|
|
|
@@ -410,7 +415,8 @@ function dig_arr_cur($hist_loop,$T,$sql_ext,$hist_time,$loop,$last_tbl,$path) {
|
|
|
// echo "<br>#296 try to ref tables for T ".$T."<pre>";
|
|
|
// print_r($tables['Z'][$T]['ref']);
|
|
|
// echo "</pre>";
|
|
|
-
|
|
|
+ $hist_loop_cur['hist_loop']=$hist_loop;
|
|
|
+ $hist_loop_cur['hist_time']=$hist_time;
|
|
|
foreach($tables['Z'][$T]['ref'] as $ref_id => $ref_table) {
|
|
|
$sql_ref=" select REMOTE_PRIMARY_KEY from `CRM__#REF_TABLE__".$ref_id."` where `PRIMARY_KEY`=".$h->ID." ";
|
|
|
$res_rel=$db->query($sql_ref) or die('211 blad '.$sql_ref);
|
|
|
@@ -421,10 +427,13 @@ function dig_arr_cur($hist_loop,$T,$sql_ext,$hist_time,$loop,$last_tbl,$path) {
|
|
|
echo "<br>#159 ref tbl ".$sql_rel_rec;
|
|
|
while($h_rel_rec=$db->fetch($res_rel_rec)){
|
|
|
echo "#315 fnd:".$h_rel_rec->ID;
|
|
|
- $hist_loop[$ref_table][]=$h_rel_rec;
|
|
|
- $hist_time[][$ref_table]=$sql_rel_rec;
|
|
|
- $hist_time[][$ref_table]=$h_rel_rec;
|
|
|
- dig_next($hist_loop,$tables['Z'][$ref_table],$h_rel_rec,$loop,$hist_time,$ref_table,add_path($path,$ref_table));
|
|
|
+ //$hist_loop[$ref_table][]=$h_rel_rec;
|
|
|
+ $hist_loop_cur['hist_loop'][$ref_table][]=$h_rel_rec;
|
|
|
+// $hist_time[][$ref_table]=$sql_rel_rec;
|
|
|
+// $hist_time[][$ref_table]=$h_rel_rec;
|
|
|
+ $hist_loop_cur['hist_time'][$ref_table][]=$sql_rel_rec;
|
|
|
+ $hist_loop_cur['hist_time'][$ref_table][]=$h_rel_rec;
|
|
|
+ dig_next($hist_loop_cur['hist_loop'],$tables['Z'][$ref_table],$h_rel_rec,$loop,$hist_loop_cur['hist_time'],$ref_table,add_path($path,$ref_table));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -434,7 +443,8 @@ function dig_arr_cur($hist_loop,$T,$sql_ext,$hist_time,$loop,$last_tbl,$path) {
|
|
|
//echo "<br>#296 try to backref tables T ".$T."<pre>";
|
|
|
// print_r($tables['Z'][$T]['backref']);
|
|
|
//echo "</pre>";
|
|
|
-
|
|
|
+ $hist_loop_cur['hist_loop']=$hist_loop;
|
|
|
+ $hist_loop_cur['hist_time']=$hist_time;
|
|
|
|
|
|
foreach($tables['Z'][$T]['backref'] as $ref_id => $ref_table) {
|
|
|
$sql_ref=" select PRIMARY_KEY from `CRM__#REF_TABLE__".$ref_id."` where `REMOTE_PRIMARY_KEY`=".$h->ID." ";
|
|
|
@@ -446,10 +456,14 @@ function dig_arr_cur($hist_loop,$T,$sql_ext,$hist_time,$loop,$last_tbl,$path) {
|
|
|
echo "<br>#324 ref tbl ".$sql_rel_rec;
|
|
|
while($h_rel_rec=$db->fetch($res_rel_rec)){
|
|
|
echo "#315 fnd:".$h_rel_rec->ID;
|
|
|
- $hist_loop[$ref_table][]=$h_rel_rec;
|
|
|
- $hist_time[][$ref_table]=$sql_rel_rec;
|
|
|
- $hist_time[][$ref_table]=$h_rel_rec;
|
|
|
- dig_next($hist_loop,$tables['Z'][$ref_table],$h_rel_rec,$loop,$hist_time,$ref_table,add_path($path,$ref_table));
|
|
|
+ // $hist_loop[$ref_table][]=$h_rel_rec;
|
|
|
+ $hist_loop_cur['hist_loop'][$ref_table][]=$h_rel_rec;
|
|
|
+
|
|
|
+ //$hist_time[][$ref_table]=$sql_rel_rec;
|
|
|
+ //$hist_time[][$ref_table]=$h_rel_rec;
|
|
|
+ $hist_loop_cur['hist_time'][$ref_table][]=$sql_rel_rec;
|
|
|
+ $hist_loop_cur['hist_time'][$ref_table][]=$h_rel_rec;
|
|
|
+ dig_next($hist_loop_cur['hist_loop'],$tables['Z'][$ref_table],$h_rel_rec,$loop,$hist_loop_cur['hist_time'],$ref_table,add_path($path,$ref_table));
|
|
|
}
|
|
|
}
|
|
|
}
|