Welcome Guest, Not a member yet? Register   Sign In
passing data to model
#1

[eluser]bigtimslim[/eluser]
What is the best way to pass data to a model. Maybe I shouldn't write best, but most common, or inline with MVC. I've seen it done these ways:

1.
Code:
function get_row($row_id)
{
    $query = $this->db->get_where('table', array('row_id' => $row_id));
    return $query->row();
}

2.
Code:
function addContact(){
  $now = date("Y-m-d H:i:s");
  $data = array(
    'name' => $this->input->xss_clean($this->input->post('name')),
    'email' => $this->input->xss_clean($this->input->post('email')),
    'notes' => $this->input->xss_clean($this->input->post('notes')),
    'ipaddress' => $this->input->ip_address(),
    'stamp' => $now
  );

  $this->db->insert('contacts', $data);
}

3. Settings the model class variables in the controller


Messages In This Thread
passing data to model - by El Forum - 03-03-2009, 08:14 PM
passing data to model - by El Forum - 03-03-2009, 08:20 PM
passing data to model - by El Forum - 03-03-2009, 08:20 PM
passing data to model - by El Forum - 03-03-2009, 08:30 PM
passing data to model - by El Forum - 03-03-2009, 08:37 PM
passing data to model - by El Forum - 03-03-2009, 08:52 PM
passing data to model - by El Forum - 03-03-2009, 09:05 PM
passing data to model - by El Forum - 03-03-2009, 09:09 PM
passing data to model - by El Forum - 03-03-2009, 09:10 PM
passing data to model - by El Forum - 03-03-2009, 09:15 PM
passing data to model - by El Forum - 03-03-2009, 09:32 PM
passing data to model - by El Forum - 03-03-2009, 09:44 PM
passing data to model - by El Forum - 03-03-2009, 09:48 PM
passing data to model - by El Forum - 03-03-2009, 09:51 PM
passing data to model - by El Forum - 03-03-2009, 09:55 PM
passing data to model - by El Forum - 03-03-2009, 10:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB