UpdateDatabase/MysqlLinks.php
[Pman.Core] / UpdateDatabase / MysqlLinks.php
index 6ea3877..409a0d7 100644 (file)
@@ -78,7 +78,34 @@ class Pman_Core_UpdateDatabase_MysqlLinks {
         $this->schema = parse_ini_file($iniCache, true);
         $this->links = parse_ini_file(preg_replace('/\.ini$/', '.links.ini', $iniCache), true);
         
-
+        $lcfg = &$this->links;
+        $cfg = HTML_FlexyFramework::get()->DB_DataObject;
+        
+        if (!empty($cfg['table_alias'])) {
+            $ta = $cfg['table_alias'];
+            foreach($lcfg  as $k=>$v) {
+                $kk = $k;
+                if (isset($ta[$k])) {
+                    $kk = $ta[$k];
+                    if (!isset($lcfg[$kk])) {
+                        $lcfg[$kk] = array();
+                    }
+                }
+                foreach($v as $l => $t_c) {
+                    $bits = explode(':',$t_c);
+                    $tt = isset($ta[$bits[0]]) ? $ta[$bits[0]] : $bits[0];
+                    if ($tt == $bits[0] && $kk == $k) {
+                        continue;
+                    }
+                    
+                    $lcfg[$kk][$l] = $tt .':'. $bits[1];
+                    
+                    
+                }
+                
+            }
+        }
+         
         
     }
     function updateTableComments()
@@ -314,7 +341,7 @@ class Pman_Core_UpdateDatabase_MysqlLinks {
             
             if (!$has_checks) {
                 echo "SKIP TRIGGER {$tbl}_before_insert (missing " . implode(", ", $errs) . ")\n";
-                return;
+                continue;
             }
             //echo $trigger; exit;
             //DB_DAtaObject::debugLevel(1);
@@ -356,11 +383,11 @@ class Pman_Core_UpdateDatabase_MysqlLinks {
                
             ";
             $has_checks=  false;
-            $err = array();
+            $errs = array();
             foreach($map as $source_col=>$target) {
                 // check that source_col exists in schema.
                 if (!isset($this->schema[$tbl][$source_col])) {
-                    $err[] = "SOURCE MISSING: $source_col => $target";
+                    $errs[] = "SOURCE MISSING: $source_col => $target";
                     continue;
                 }
                 
@@ -370,7 +397,7 @@ class Pman_Core_UpdateDatabase_MysqlLinks {
                 
                 if (!isset($this->schema[$target_table])) {
                     // skip... target table does not exist
-                    $err[] = "TARGET MISSING: $source_col => $target";
+                    $errs[] = "TARGET MISSING: $source_col => $target";
                     continue;
                 }
                 
@@ -401,8 +428,8 @@ class Pman_Core_UpdateDatabase_MysqlLinks {
            
             ";
             if (!$has_checks) {
-                echo "SKIP TRIGGER {$tbl}_before_update (missing " . implode(", ", $err) . ")\n";
-                return;
+                echo "SKIP TRIGGER {$tbl}_before_update (missing " . implode(", ", $errs) . ")\n";
+                continue;
             }
             
             //echo $trigger; exit;
@@ -412,11 +439,6 @@ class Pman_Core_UpdateDatabase_MysqlLinks {
             echo "CREATED TRIGGER {$tbl}_before_update\n";
             
             
-            
-            
-            
-            
-            
         }