February 1st, 2013, 05:58 AM
Is it proper? Loading helpers and doing things other than database actions in model?
I was reading Codeigniter's document and I ran into this model.
I am a bit surprised there are few things here that could be moved to controller. Would you change this model and put some of this in controller?
public function set_news()
$slug = url_title($this->input->post('title'), 'dash', TRUE);
$data = array(
'title' => $this->input->post('title'),
'slug' => $slug,
'text' => $this->input->post('text')
return $this->db->insert('news', $data);
February 1st, 2013, 08:58 AM
they probably did it to keep controller file SKINNY.. in general controllers should not do any processing.. Models should do all the work..
February 2nd, 2013, 02:41 AM
Why not putting thoses processes in helper or library rather than model (which brings me to the next question, what is the difference between helpers and libraries)?
Originally Posted by paulh1983
Last edited by zxcvbnm; February 2nd, 2013 at 04:01 AM.
February 4th, 2013, 12:12 PM
libraries are like classes. helper is just any old file with bunch of function stuck together.
this is what i understand anyway. Could be wrong