Welcome Guest, Not a member yet? Register   Sign In
What to use the model for?
#1

[eluser]loonychune[/eluser]
I'm using the model to make various queries on my database.

I was also wondering if you think a model could be used to scan directories, or should this be done by a controller?

Also, what about when using cURL to to grab data from YQL or some other external resource? This feels to me like it should be firmly in the realm of the model also.

Your thoughts are much appreciated Smile
#2

[eluser]wiredesignz[/eluser]
A model establishes the application state, which can be anything other than managing the incoming HTTP request or outgoing response.

Read this very good explanation of the MVC design pattern. http://www.phpwact.org/pattern/model_view_controller
#3

[eluser]BrianDHall[/eluser]
Don't forget about the concept of libraries - there is a library for curl itself in CI, for instance.

The above link is a good one. In a really small nutshell, models are concerned with your applications data and certain manipulations of it. So you might have a billing Model that would fully encapsulate the table you use for your billing information, and have functions such as adding a payment, reversing a payment, getting a clients payment history, etc.

For things like curl and parsing YQL it seems like it fits the use of libraries, while the Model might invoke the library to get the data from YQL it needs - and then the model handles its storing and manipulations and such.
#4

[eluser]wiredesignz[/eluser]
Libraries do not feature in the MVC design pattern for good reason. A library that does the job of a model is a model.




Theme © iAndrew 2016 - Forum software by © MyBB