Welcome Guest, Not a member yet? Register   Sign In
Model and Form
#1

(This post was last modified: 11-20-2014, 04:14 AM by aurelien.)

Hello,

I'm new user of MVC and I have a few questions regarding Models.

If you read this tutorial you can see

Model
PHP Code:
public function set_news()
{
 
   $this->load->helper('url');

 
   $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);


Why is it better to read inputs from Forms into Models rather than into Controllers ?
Is it not "more MVC" to read inputs from Forms into Controllers ?

Like this
Controller
PHP Code:
public function create()
{
 
   ...
 
   $this->load->helper('url');

 
   $slug url_title($this->input->post('title'), 'dash'TRUE);

 
   $data = array(
 
       'title' => $this->input->post('title'),
 
       'slug' => $slug,
 
       'text' => $this->input->post('text')
 
   );

 
  $this->news_model->set_news($data);


Model
PHP Code:
public function set_news($data)
{
 
   return $this->db->insert('news'$data);



Thanks for your help !  Smile
Reply


Messages In This Thread
Model and Form - by aurelien - 11-20-2014, 03:24 AM
RE: Model and Form - by Rufnex - 11-20-2014, 04:10 AM
RE: Model and Form - by ivantcholakov - 11-20-2014, 05:00 AM
RE: Model and Form - by bclinton - 11-20-2014, 07:59 AM
RE: Model and Form - by slax0r - 11-20-2014, 04:11 PM
RE: Model and Form - by RobertSF - 11-20-2014, 05:59 PM
RE: Model and Form - by bclinton - 11-20-2014, 07:26 PM
RE: Model and Form - by slax0r - 11-21-2014, 01:43 AM
RE: Model and Form - by bclinton - 12-12-2014, 04:58 PM
RE: Model and Form - by mwhitney - 12-12-2014, 03:21 PM
RE: Model and Form - by bclinton - 12-12-2014, 04:55 PM
RE: Model and Form - by mwhitney - 12-15-2014, 10:02 AM
RE: Model and Form - by jaynarayan - 12-18-2015, 10:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB