diff --git a/api/application/models/Data_Dump_Model.php b/api/application/models/Data_Dump_Model.php index ca62b254..0bc681e5 100755 --- a/api/application/models/Data_Dump_Model.php +++ b/api/application/models/Data_Dump_Model.php @@ -80,22 +80,21 @@ class Data_Dump_Model extends SPARQ_Model { $prod = isset($arr['product_id'])?$arr['product_id']:null; $cseg = isset($arr['customer_segment_id'])?$arr['customer_segment_id']:null; ### 2 tables t_pd_form_details_json and t_pd_triggered - $this->db->select('PDFORMDETAILSJSON.pd_form_detail_json_id, PDFORMDETAILSJSON.fk_pd_id, PDFORMDETAILSJSON.fk_form_id, PDFORMDETAILSJSON.isactive, PDFORMDETAILSJSON.json, DATE_FORMAT(PDFORMDETAILSJSON.createdon,"%d/%m/%Y %H:%i:%s") as createdon, PDFORMDETAILSJSON.processed_json, PDFORMDETAILSJSON.updatedon,PDTRIGGER.completed_on,PDTRIGGER.fk_product_id, PDTRIGGER.fk_customer_segment,PDTRIGGER.fk_pd_type,PDTRIGGER.pd_status,PDTRIGGER.createdon'); + $this->db->select('PDFORMDETAILSJSON.pd_form_detail_json_id, PDFORMDETAILSJSON.fk_pd_id, PDFORMDETAILSJSON.fk_form_id, PDFORMDETAILSJSON.isactive, PDFORMDETAILSJSON.json, DATE_FORMAT(PDFORMDETAILSJSON.createdon,"%d/%m/%Y %H:%i:%s") as createdon, PDFORMDETAILSJSON.processed_json, PDFORMDETAILSJSON.updatedon,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %H:%i:%s") as completed_on,PDTRIGGER.fk_product_id, PDTRIGGER.fk_customer_segment,PDTRIGGER.fk_pd_type,PDTRIGGER.pd_status,PDTRIGGER.createdon'); $this->db->from(PDFORMDETAILSJSON.' as PDFORMDETAILSJSON'); $this->db->join(PDTRIGGER.' as PDTRIGGER','PDTRIGGER.pd_id = PDFORMDETAILSJSON.fk_pd_id ','LEFT'); - if(!empty($pdid)) { $this->db->where_in('PDFORMDETAILSJSON.fk_pd_id',$pdid); } if(($fromd != "" || $fromd != null) && ($tod != "" || $tod != null)) { - $this->db->where('PDTRIGGER.createdon BETWEEN '. "'$fromd'". ' AND '. "'$tod'" ); + $this->db->where('PDTRIGGER.completed_on BETWEEN '. "'$fromd'". ' AND '. "'$tod'" ); } else if($fromd != "" && $fromd != null) { - $this->db->where("DATE_FORMAT(PDTRIGGER.createdon,'%Y-%m-%d')",$fromd); + $this->db->where("DATE_FORMAT(PDTRIGGER.completed_on,'%Y-%m-%d')",$fromd); } else if($tod != "" && $tod != null) { - $this->db->where("DATE_FORMAT(PDTRIGGER.createdon,'%Y-%m-%d')",$tod); + $this->db->where("DATE_FORMAT(PDTRIGGER.completed_on,'%Y-%m-%d')",$tod); } if($prod != ""){ $this->db->where('PDTRIGGER.fk_product_id',$prod); @@ -108,8 +107,9 @@ class Data_Dump_Model extends SPARQ_Model { } $this->db->WHERE('PDFORMDETAILSJSON.isactive',1); $this->db->order_by('PDFORMDETAILSJSON.pd_form_detail_json_id','desc'); + $this->db->limit(5); $result = $this->db->get()->result_array(); - // echo count($result);print_r($result);print_r($this->db->last_query());die(); + echo count($result);print_r($result);print_r($this->db->last_query());die(); return $result; }