<?php

class CommonModel extends CI_Model {

	function __construct()
    {
        parent::__construct();		
    }


    public function getWhere($a, $b, $c) {
        $data = array();
        $query = $this->db->get_where($a, array($b => $c));  //echo $data1 = $this->db->last_query();
        foreach ($query->result_array() as $row) {
            $data[] = $row;
        }
        return $data;
    }



    public function getAllData($a) {
        $data = array();
        $query = $this->db->get($a);
        foreach ($query->result_array() as $row) {
            $data[] = $row;
        }return $data;
    } 


    function insert($table,$data) {

        $this->db->insert($table,$data);
    }

    function edit_data($table,$field,$val,$update_val) {

       $this->db->where($field,$val)->update($table,$update_val);
    }
   

    public function fetch_a_row($field_name,$field_value,$table_name)
    {
        $this->db->where($field_name, $field_value);
        $query = $this->db->get($table_name);
        
        $result=$query->result();
        return $result[0];
    }

    public function del($field_name,$field_value,$table_name)
    {
        $this->db->where($field_name, $field_value);
        $this->db->delete($table_name);
        
    }

    public function banner_count($param)
    {

       if (isset($param['banner_heading']) && $param['banner_heading'] != '') {
            $this->db->like('banner_heading', $param['banner_heading']);
        }

        $this->db->from('banner');
        $total_rows=$this->db->count_all_results();

        return $total_rows;

    }

    public function all_banner_list($limit,$start,$param)
    {

        if (isset($param['banner_heading']) && $param['banner_heading'] != '') {
            $this->db->like('banner_heading', $param['banner_heading']);
        }

        $this->db->order_by("banner_index", "asc");
        $this->db->limit($limit,$start);
        $data = $this->db->get('banner')->result_array();

        return $data;
    }


}
?>