Go to application/model
File name - Home_model.php
Inside the file
class Home_model extends CI_Model {
public $variable;
public function __construct()
{
parent::__construct();
}
public function get_data()
{
$query = $this->db->get('table_name', 10);
return $query->result_array();
}
}
And when you need to load this model:
$this->load->model('home_model');
$this->home_model->get_data();
Or If you would like your model assigned to a different object name you can specify it like this:
$this->load->model('home_model', 'home');
$this->home->get_data();