0

Possible Duplicate:
CodeIgniter and the Model-View-Controller – your experience / your meaning?

I am guessing quite a simple question. With PHP and an MVC framework such as Codeigniter, is it better practice to always pass variables to the model? For example, should you pass post variables through the method call or directly reference $this->input->post() in the method itself? I am guessing it is best to pass them because you cannot assume the parameters will always come from the same source?

Thanks,

Tom

Community
  • 1
  • 1
Thomas Maddocks
  • 1,355
  • 9
  • 24

2 Answers2

2

I would say that you should pass the parameters. Post input is only there when running in a web server. When running from the command line (CLI), there is no input from post.

The model should not be aware of this.

JvdBerg
  • 21,777
  • 8
  • 38
  • 55
2

Following common design principles your self given answer is correct: For e.g. reusability reasons different concerns should not be mixed within modules or classes. The model is responsible for handling the model properties and behavior - regardless where your data is coming from.

matthias
  • 2,255
  • 1
  • 23
  • 28