Welcome Guest, Not a member yet? Register   Sign In
Validation -> Model
#5

[eluser]Colin Williams[/eluser]
I personally don't like the model accessing $_POST data because that, in a way, couples the model too tightly with the view (what if the data is retrieved by means other than a posted form, like CSV imports, etc). Typically all of my insert-type model functions accept an object to save (or array) which it filters through to remove unneeded properties before doing the SQL. Then a controller can just pass it $_POST, as in the examples above.

Code:
function update()
{
   if ($this->blog_model->save($_POST)
   {
      // Update worked
   }
}


Messages In This Thread
Validation -> Model - by El Forum - 01-20-2010, 12:19 PM
Validation -> Model - by El Forum - 01-20-2010, 01:13 PM
Validation -> Model - by El Forum - 01-20-2010, 01:28 PM
Validation -> Model - by El Forum - 01-20-2010, 03:52 PM
Validation -> Model - by El Forum - 01-20-2010, 05:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB