Bläddra i källkod

mapeo de tablas brutas a limpias para duplicateOnKey

Nermosis 3 år sedan
förälder
incheckning
6f8d139100
2 ändrade filer med 33 tillägg och 15 borttagningar
  1. 15 15
      application/libraries/Parserdatabaselimpio.php
  2. 18 0
      application/models/Parser_model.php

+ 15 - 15
application/libraries/Parserdatabaselimpio.php Visa fil

@@ -1,34 +1,34 @@
1 1
 <?php
2 2
 defined('BASEPATH') or exit('No direct script access allowed');
3 3
 
4
-/**
5
- *
6
- * Libraries Parserdatabaselimpio
7
- *
8
- * This Libraries for ...
9
- *
10
- * @package        CodeIgniter
11
- * @category    Libraries
12
- * @author    Setiawan Jodi <jodisetiawan@fisip-untirta.ac.id>
13
- * @link      https://github.com/setdjod/myci-extension/
14
- * @param     ...
15
- * @return    ...
16
- *
17
- */
18
-
19 4
 class Parserdatabaselimpio
20 5
 {
21 6
 
7
+    //TODO: Vincular nombre de columnas en bruto con nombres de columnas en maestros
22 8
     protected $CI;
23 9
 
24 10
     public function __construct()
25 11
     {
26 12
         $this->CI = &get_instance();
13
+        $this->CI->load->model("Parser_model");
27 14
     }
28 15
 
29 16
     public function index()
30 17
     {
18
+        $now = date("Y-m-d_H-i-s");
19
+        $tablasInsert = $this->CI->Parser_model->getMapaTablas();
20
+
21
+        if ($tablasInsert['num_rows'] > 0) {
22
+
23
+            foreach ($tablasInsert['datos'] as $row) {
24
+
25
+                $datosTablaToInsert = $this->CI->Parser_model->getDatosBrutos($row->tabla_sucia);
31 26
 
27
+                if ($datosTablaToInsert['num_rows'] > 0) {
28
+                    insertBucleDuplicateOnKey($datosTablaToInsert['datos'], $row->tabla_maestra, "brutoToMaestro_" . $now);
29
+                }
30
+            }
31
+        }
32 32
     }
33 33
 
34 34
 }

+ 18 - 0
application/models/Parser_model.php Visa fil

@@ -72,6 +72,24 @@ class Parser_model extends CI_Model
72 72
         return $this->db->insert_id();
73 73
     }
74 74
 
75
+    public function getMapaTablas()
76
+    {
77
+        $sql = "SELECT * FROM mapa_tablas_parser ORDER BY orden ASC";
78
+        $result = $this->db->query($sql);
79
+        $datos['datos'] = $result->result();
80
+        $datos['num_rows'] = $result->num_rows();
81
+        return $datos;
82
+    }
83
+
84
+    public function getDatosBrutos($tabla)
85
+    {
86
+        $sql = "SELECT * FROM $tabla";
87
+        $result = $this->db->query($sql);
88
+        $datos['datos'] = $result->result();
89
+        $datos['num_rows'] = $result->num_rows();
90
+        return $datos;
91
+    }
92
+
75 93
 }
76 94
 
77 95
 /* End of file Parser_model.php */