<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of mira_worker_tracking_activity
 *
 * @author zmq163
 */
class Mira_worker_tracking_activity extends CI_Model{
    //put your code here
    var $mdb;
    public function __construct() {
        parent::__construct();
        $this->mdb=$this->load->database('mdb',TRUE);
    }
    /**
     * 
     * 
     * 
     */
    public function getPregnantWomenTracking($_pregnant_id=NULL,$_week_id=NULL){
        if($_pregnant_id!=NULL and $_week_id!=NULL){
            $this->mdb->select('*');
            $this->mdb->from('common_module_tracker');
            $this->mdb->join('common_module_sub_menu_tracker','common_module_sub_menu_tracker.module_id=common_module_tracker.comm_module_id','INNER');
            $this->mdb->join('common_module_tracker_pregnant','common_module_tracker_pregnant.common_module_id=common_module_tracker.comm_module_id','INNER');
            $this->mdb->where(array('common_module_tracker_pregnant.pregnant_id'=>$_pregnant_id,'common_module_tracker_pregnant.week_id'=>$_week_id));
            $this->mdb->order_by('common_module_tracker.comm_module_id', 'desc');
            $this->mdb->limit(5,0);
     
            return $this->getData($this->mdb->get());
           // select * from  inner join  on  inner join  on  where pregnant_id=759 and week_id=23;

        }  else {
            return FALSE;    
        }
    }
    /**
     * 
     * 
     * 
     * 
     */
    private function getData($_query=NULL){
        if($_query!=NULL and $_query->num_rows()>0){
            return $_query->result_array();
        }  else {
            return FALSE;    
        }
    }
}
