Welcome Guest, Not a member yet? Register   Sign In
Access $this->validation->Name inside Models
#4

[eluser]Randy Casburn[/eluser]
Quote: However, I like to keep my models from having to worry about the HTTP request because this is the job of the controller.

This will be more philosophical than anything. This is somewhat like a religion...

For a point of clarity I would like to address your point though. By the time the Controller has the data, the Controller should have already done its job and reacted to any events in queue. At this point all that is left is data sitting and waiting to be operated upon. In other words, after the Controller has ensured validation and XSS etc. as stated here (from: Benedikt)

Quote:Now, after all data is confirmed and correct, I want it to be saved into the database.

Then the HTTP request (Event) has already been handled and we are in a steady state with nothing to do but process data.

=====

So from a design perspective, you're sitting on a boundary condition (Controller <-> Model) with sanitized data loaded in an object and no events to operate on whatsoever.

Now this is from the CI user guide:
Quote:The Model represents your data structures. Typically your model classes will contain functions that help you retrieve, insert, and update information in your database.
And an excerpt from ootips.org (really should read it all): http://ootips.org/mvc-pattern.html
Quote:[The model is used] to manage information and notify observers when that information changes. [...] It contains only data and functionality that are related by a common purpose [...]
====

So Benedikt I hope this helps you understand how to choose to put functionality in the Controller or the Model. Please keep in mind this doesn't apply to every case and there are many opinions about these things.

Randy


Messages In This Thread
Access $this->validation->Name inside Models - by El Forum - 07-12-2008, 03:56 PM
Access $this->validation->Name inside Models - by El Forum - 07-12-2008, 04:13 PM
Access $this->validation->Name inside Models - by El Forum - 07-12-2008, 07:46 PM
Access $this->validation->Name inside Models - by El Forum - 07-12-2008, 09:48 PM
Access $this->validation->Name inside Models - by El Forum - 07-12-2008, 11:01 PM
Access $this->validation->Name inside Models - by El Forum - 07-12-2008, 11:36 PM
Access $this->validation->Name inside Models - by El Forum - 07-13-2008, 12:07 AM
Access $this->validation->Name inside Models - by El Forum - 07-13-2008, 01:16 AM
Access $this->validation->Name inside Models - by El Forum - 07-13-2008, 03:15 AM
Access $this->validation->Name inside Models - by El Forum - 07-13-2008, 03:20 AM
Access $this->validation->Name inside Models - by El Forum - 07-13-2008, 03:21 AM
Access $this->validation->Name inside Models - by El Forum - 07-13-2008, 03:23 AM
Access $this->validation->Name inside Models - by El Forum - 07-13-2008, 03:33 AM
Access $this->validation->Name inside Models - by El Forum - 07-13-2008, 09:38 AM
Access $this->validation->Name inside Models - by El Forum - 07-13-2008, 09:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB