Welcome Guest, Not a member yet? Register   Sign In
Passing Data To Model
#6

[eluser]onisemus[/eluser]
I agree with a couple of other posts here. The model should act as a black box. It's your "Data Access Layer", and the only thing it should be about it accessing your data. That means keeping things such as reading post values away from it. Get the post values in the controller. Then pass those values to the model.

The advantage of this is that it lets your different layers (Model, View, and Controller) be loosely coupled. For example, if your view changes (say a input field name), you don't necessarily have to go update the model because its just passing a value. If your model changes (and database column name), your view doesn't necessarily have to change, because it doesn't care about the database field names.

One other alternative, if you want to keep your controller code clean is to create a helper that the controller invokes, which passes all the values to the model for you.

Hope that helps!


Messages In This Thread
Passing Data To Model - by El Forum - 11-29-2007, 07:26 PM
Passing Data To Model - by El Forum - 11-29-2007, 08:08 PM
Passing Data To Model - by El Forum - 11-30-2007, 03:45 AM
Passing Data To Model - by El Forum - 11-30-2007, 03:49 AM
Passing Data To Model - by El Forum - 11-30-2007, 04:23 AM
Passing Data To Model - by El Forum - 12-04-2007, 06:01 PM
Passing Data To Model - by El Forum - 12-04-2007, 06:38 PM



Theme © iAndrew 2016 - Forum software by © MyBB