Parser_model.php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. return $datos;
  49. }
  50. public function getUrlArchivos()
  51. {
  52. $sql = "SELECT * FROM tipo_licitacion_tablas";
  53. $result = $this->db->query($sql);
  54. $datos['datos'] = $result->result();
  55. $datos['num_rows'] = $result->num_rows();
  56. return $datos;
  57. }
  58. public function setInicioLicitacion($licitacionArr)
  59. {
  60. $this->db->insert('BRUTO_datos_iniciales', $licitacionArr);
  61. return $this->db->insert_id();
  62. }
  63. public function getMapaTablas()
  64. {
  65. $sql = "SELECT * FROM mapa_tablas_parser ORDER BY orden ASC";
  66. $result = $this->db->query($sql);
  67. $datos['datos'] = $result->result();
  68. $datos['num_rows'] = $result->num_rows();
  69. return $datos;
  70. }
  71. public function truncateTables($tabla)
  72. {
  73. $this->db->truncate($tabla);
  74. }
  75. public function getDatosBrutos($tabla)
  76. {
  77. $sql = "SELECT * FROM $tabla";
  78. $result = $this->db->query($sql);
  79. $datos['datos'] = $result->result();
  80. $datos['num_rows'] = $result->num_rows();
  81. return $datos;
  82. }
  83. public function getLicitacionesNuevasBruto()
  84. {
  85. $sql = "SELECT DISTINCT id_licitacion FROM bruto_datos_iniciales";
  86. $result = $this->db->query($sql);
  87. $datos['num_rows'] = $result->num_rows();
  88. return $datos;
  89. }
  90. public function deleteCascadaNuevasLicitaciones()
  91. {
  92. $sql = "DELETE
  93. FROM maestro_datos_iniciales_licitacion
  94. WHERE id_licitacion IN(
  95. SELECT DISTINCT id_licitacion FROM bruto_datos_iniciales
  96. )";
  97. $result = $this->db->query($sql);
  98. $datos['num_rows'] = $this->db->affected_rows();
  99. return $datos;
  100. }
  101. public function getMapaByTabla($tabla)
  102. {
  103. $sql = "SELECT * FROM $tabla";
  104. $result = $this->db->query($sql);
  105. $datos['datos'] = $result->result();
  106. $datos['num_rows'] = $result->num_rows();
  107. return $datos;
  108. }
  109. }
  110. /* End of file Parser_model.php */
  111. /* Location: ./application/models/Parser_model.php */