Let suppose you are calling a model index in controller index
Class test_controller extends CI_Controller
{
function index(){
$this->load->model('model_name');
$this->model_name->model_index();
}
}
Now when ever you redirect to Controller index the model index will be called automatically.
EDITS:
How ever , you can use it like this
Class test_controller extends CI_Controller
{
function index(){
$query = $this->db->get('my_table');
$data['query_result'] = $query->result();
}
}
And model index is this
function index()
{
$query = $this->db->get('my_table');
return $query->result();
}
You should note model index is not called here instaed model has been useless we are doing work without it. So seperating the database interaction is usefull and combining it with controller breaks the MVC pattren.