Dynamic Controller And Model (First Date,End Date)
Controller...... $FirstDate = date('Y-m-d', strtotime('-30 days')).' 00:00:01'; $firstDateToFetch = date('Y-m-d', strtotime($FirstDate)) ; $endDateToFetch = ''; $condition = array(); $sales = $this->model->calculate('ppc_campaignspref',$firstDateToFetch,$endDateToFetch,$condition,'attributedSales30d','sales'); Model....... public function calculate($tableName,$fromDate,$endDate=null,$condition,$column1=null,$asValue=null){ $this->db->select("SUM(".$tableName.".".$column1.") as ".$asValue);//changed attributedSales1d) as Sales $this->db->from($tableName); (($fromDate!='')?$this->db->where('dayOfData >=', $fromDate) : ''); (($endDate!='')?$this->db->where('dayOfData...