Parser_model.php 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. defined('BASEPATH') or exit('No direct script access allowed');
  3. /**
  4. *
  5. * Model Parser_model
  6. *
  7. * This Model for ...
  8. *
  9. * @package CodeIgniter
  10. * @category Model
  11. * @author Setiawan Jodi <jodisetiawan@fisip-untirta.ac.id>
  12. * @link https://github.com/setdjod/myci-extension/
  13. * @param ...
  14. * @return ...
  15. *
  16. */
  17. class Parser_model extends CI_Model
  18. {
  19. // ------------------------------------------------------------------------
  20. public function __construct()
  21. {
  22. parent::__construct();
  23. }
  24. public function inicioParser()
  25. {
  26. $data = array(
  27. 'cron_ejecucion' => 1,
  28. "fecha_ejecucion" => date("Y-m-d h:i:s"),
  29. );
  30. $this->db->where('id', 0);
  31. $this->db->update('parametros_cron', $data);
  32. }
  33. public function stopParser()
  34. {
  35. $data = array(
  36. 'cron_ejecucion' => 0,
  37. "fecha_ejecucion" => date("Y-m-d h:i:s"),
  38. );
  39. $this->db->where('id', 0);
  40. $this->db->update('parametros_cron', $data);
  41. }
  42. public function existCronRun()
  43. {
  44. $sql = "SELECT * FROM parametros_cron";
  45. $result = $this->db->query($sql);
  46. $datos['datos'] = $result->row();
  47. $datos['num_rows'] = $result->num_rows();
  48. $result->free_result();
  49. return $datos;
  50. }
  51. public function getUrlArchivos()
  52. {
  53. $sql = "SELECT * FROM tipo_licitacion_tablas";
  54. $result = $this->db->query($sql);
  55. $datos['datos'] = $result->result();
  56. $datos['num_rows'] = $result->num_rows();
  57. $result->free_result();
  58. return $datos;
  59. }
  60. public function setInicioLicitacion($licitacionArr)
  61. {
  62. $this->db->insert('BRUTO_datos_iniciales', $licitacionArr);
  63. return $this->db->insert_id();
  64. }
  65. public function getMapaTablas()
  66. {
  67. $sql = "SELECT * FROM mapa_tablas_parser ORDER BY orden ASC";
  68. $result = $this->db->query($sql);
  69. $datos['datos'] = $result->result();
  70. $datos['num_rows'] = $result->num_rows();
  71. $result->free_result();
  72. return $datos;
  73. }
  74. public function truncateTables($tabla)
  75. {
  76. $this->db->truncate($tabla);
  77. }
  78. public function getDatosBrutos($tabla)
  79. {
  80. $sql = "SELECT * FROM $tabla";
  81. $result = $this->db->query($sql);
  82. $datos['datos'] = $result->result();
  83. $datos['num_rows'] = $result->num_rows();
  84. $result->free_result();
  85. return $datos;
  86. }
  87. public function getLicitacionesNuevasBruto()
  88. {
  89. $sql = "SELECT DISTINCT id_licitacion FROM bruto_datos_iniciales";
  90. $result = $this->db->query($sql);
  91. $datos['datos'] = $result->result();
  92. $datos['num_rows'] = $result->num_rows();
  93. $result->free_result();
  94. return $datos;
  95. }
  96. public function deleteCascadaNuevasLicitaciones()
  97. {
  98. $sql = "DELETE
  99. FROM maestro_datos_iniciales_licitacion
  100. WHERE id_licitacion IN(
  101. SELECT DISTINCT id_licitacion FROM bruto_datos_iniciales
  102. )";
  103. $result = $this->db->query($sql);
  104. $datos['num_rows'] = $this->db->affected_rows();
  105. return $datos;
  106. }
  107. public function getMapaByTabla($tabla)
  108. {
  109. $sql = "SELECT * FROM $tabla";
  110. $result = $this->db->query($sql);
  111. $datos['datos'] = $result->result();
  112. $datos['num_rows'] = $result->num_rows();
  113. $result->free_result();
  114. return $datos;
  115. }
  116. }
  117. /* End of file Parser_model.php */
  118. /* Location: ./application/models/Parser_model.php */