Using CodeIgniter, or any MVC framework, provided that the Model is the database wrapper and Controller must not contain any information about database or any connection with database.
Now, if a person create a generic Model class say "DB_Model" with a method
add($table, $fields)
To use this method, that person must call it from a Controller as
$this->DB_Model->add('my_table_name', $fields)
Now, the question is, isn't this wrong by the definition of a Model-View-Controller framework? I mean, the Controller now got information about the database.
Thanks
EDIT: I am not questioning CI but just the above practice that some people do to spend less time on applications, coding.
So the way CI works is
create a method in the model where the actual DB work is done. https://www.codeigniter.com/user_guide/general/models.html
create a controller that calls the model:
class Blog_controller extends CI_Controller {
public function blog()
{
$this->load->model('blog');
$data['query'] = $this->blog->get_last_ten_entries();
$this->load->view('blog', $data);
}
}
example taken from link above.
edit: yeah it's wrong in my opinion, it's not correctly decoupled the way they told you (?).