<?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 expencecategorymodel
 *
 * @author BusyMan
 */
class ExpenceCategoryModel extends CI_Model {
    //put your code here
    private $_tbl_EC = 'tbl_expensecategory';

    public function saveExpensecategory($data) {
        $this->db->insert($this->_tbl_EC, $data);
        return $this->db->insert_id();
    }

    public function getAllExpenseCategory(){
    	$query=$this->db->get($this->_tbl_EC);
    	$result=$query->result_array();
    	if(!empty($result)){
    		return $result;
    	}
    }

    public function getexpenseCategoryById($id){
       $query=$this->db->get_where($this->_tbl_EC,array('category_id'=>$id));
        $result=$query->row_array();
        if(!empty($result)){
            return $result;
        } 
    }

    public function updateExpensecategory($data,$category_id)
    {
        $this->db->update($this->_tbl_EC,$data,array('category_id'=>$category_id));
        return $this->db->affected_rows();
    }

    public function deleteExpensecategory($category_id){
        $this->db->delete($this->_tbl_EC,array('category_id'=>$category_id));
        return $this->db->affected_rows();
    }


}
