<?php

/*
 * Model_orkin.php
 *
 * Created on March 30, 2017, 10:46 PM
 *
*/

/**
 <P>This class is used to execute Orkin Get Requests

 @author Giovanni G. Mendez M.
 @see RMScheduler
 */

class Model_orkin extends CI_Model {

	//var $db;
	var $b14_2;

    function __construct() {
    	parent::__construct();
    	$this->db = $this->load->database('default',TRUE);
    	
    }

	public function execute_query($query) {   
		$this->db->db_select("default");
		//var_dump($query);            
        $result = $this->db->query($query);

		return $result;
	}

	public function test() {   
		$this->db->db_select("default");  
		$query = "select id,seriesId,location,start_date,end_date,text,personnel,vehicle,customer,calendar from rmscheduler_orkincr.eventsPermanent where YEAR(start_date) = YEAR(DATE_SUB(CURDATE(), INTERVAL 1 YEAR)) order by start_date,end_date,customer,location";
        $result = $this->db->query($query);
		return $result;
	}
	
	public function execute_query_define($query) {   
		$this->db->db_select("define"); 
		$this->db['define']['database'] = 'rmscheduler_orkincr';           
        $result = $this->db->query($query);

		return $result;
	}

	public function execute_query_b14_2($query) {  
		$this->b14_2 = $this->load->database('b142',TRUE);
		$this->db->db_select("b142"); 
		$result = $this->b14_2->query($query);

		return $result;
	}

	public function execute_query_AWS($query) {  
		$this->db->db_select("AWS"); 
		$result = $this->AWS->query($query);
		return $result;
	}
	
	
	public function execute_queryInsert($query) {   
		$this->db->db_select("default");            
		$insert = $this->db->insert('automaticReportDefinitions',$query);
        $insert_id = $this->db->insert_id();

		return $insert_id;
	}
	
	
}

?>
