Browse Source

Adding more corrections see BT#4875

Julio Montoya 12 years ago
parent
commit
80d299d6b2

+ 1 - 0
tests/migrate/migrate.php

@@ -5,6 +5,7 @@
  */
 require_once '../../main/inc/global.inc.php';
 require_once 'config.php';
+
 if (is_file(dirname(__FILE__) . '/migration.custom.class.php')) {
     require_once 'migration.custom.class.php';
 } else {

+ 14 - 8
tests/migrate/migration.class.php

@@ -128,11 +128,13 @@ class Migration {
                 error_log('No fields found');
                 continue;
             }
-            //if ($this->num_rows) {
-            if (1) {
-                error_log('Records found: '.$this->num_rows);
-                while ($row = $this->fetch_row()) {
-                    error_log(print_r($row, 1));
+            
+            $num_rows = $this->num_rows();
+            
+            if ($num_rows) {            
+                error_log('Records found: '.$num_rows);
+                while ($row = $this->fetch_array()) {
+                    //error_log(print_r($row, 1));
                     $dest_row = array();
                     $first_field = '';
                     foreach ($table['fields_match'] as $id_field => $details) {
@@ -148,13 +150,17 @@ class Migration {
                         $dest_row[$details['dest']] = $dest_data;
                     }
                     if (!empty($table['dest_func'])) {
-                        error_log('Calling MigrationCustom::' . $table['dest_func'] . ' on data recovered: ' . print_r($dest_row, 1));
-                        //$table['dest_func']($dest_row);
+                        error_log('Calling ' . $table['dest_func'] . ' on data recovered: ' . print_r($dest_row, 1));
+                        call_user_func_array($table['dest_func'], array($dest_row));                        
                     } else {
                         $this->errors_stack[] = "No destination data dest_func found. Abandoning data with first field $first_field = " . $dest_row[$first_field];
                     }
-                }
+                }                
                 error_log('Finished processing table ' . $table['orig_table']."\n\n");
+                
+                if ($table['orig_table'] == 'ProgramaAcademico')  {
+                    exit;
+                }
             } else {
                 error_log('No records found');
             }

+ 1 - 1
tests/migrate/migration.custom.class.php

@@ -52,7 +52,7 @@ class MigrationCustom {
         $omigrate['sessions'][$data] = 0;
     }
     
-    public function store_user_data1() {
+    public function store_user_data($data = array()) {
         
     }
 }

+ 9 - 4
tests/migrate/migration.mssql.class.php

@@ -30,20 +30,25 @@ class MigrationMSSQL extends Migration {
         if (!empty($fields_sql)) {
             $fields_sql = substr($fields_sql, 0, -2);
         }
-        $sql = "SELECT $fields_sql FROM $table";
+        //In order to process X item of each table add TOP X
+        $sql = "SELECT TOP 1 $fields_sql FROM $table";
         //remove
         error_log($sql);
         $this->rows_iterator = mssql_query($sql, $this->c);
         
         if ($this->rows_iterator  === false) {
-            error_log("--- Error with query ".$sql." MSSQL error: ".mssql_get_last_message()."-- \n");
+            error_log("--- Error with query $sql MSSQL error: ".mssql_get_last_message()."-- \n");
         }
     }
 
     public function fetch_row() {        
         return mssql_fetch_row($this->rows_iterator);
     }
+    
+    public function fetch_array() {        
+        return mssql_fetch_array($this->rows_iterator, MSSQL_ASSOC);
+    }
     public function num_rows() {
         return mssql_num_rows($this->rows_iterator);
-    }    
-}
+    }
+}