FBwall
FBwall

Reputation: 1653

Use of models in FuelPHP?

I'm new to PHP frameworks and to start my venture I went to try FuelPHP. After a few days of testing around I understood how things work. Controllers control the actions, views control the $content and the template controls the layout. But what about models, What are they for?

Upvotes: 0

Views: 191

Answers (3)

Tony Hopkinson
Tony Hopkinson

Reputation: 20320

You might have say

Contact With ID,Name,Detail and ContactType properties.

The idea is to keep it minimal it's basically something to cart around all the useful properties of an entity.

This is the current definition of MVC. Nothing about the backend in it. That would be some seperate library / dll that only knows about model, and how the underlying data is stored in the DB.

Upvotes: 0

LeleDumbo
LeleDumbo

Reputation: 9340

Models are abstractions over data stored elsewhere, they encapsulate the data access through standard object creation, method calls, property access, etc. just like ordinary objects. The main idea here is that the controller (or whatever object that requires the data) doesn't need to know how to get the data or how it's stored. It could be stored in files, web (via webservice), database, whatever thing that could persist data. The data could be retrieved with webservice request, database query, file reading, etc.

For instance, "gimme student record with id 1" could be as simple as student := new student(1); and after that you have access to the student's name, address, etc. But how does the student retrieve its data? Where does it store the data? It's out of concern and could be tuned (or should be tunable) as needed.

Upvotes: 2

kosaidpo
kosaidpo

Reputation: 461

models controle your data and have a direct contact with your db have a read here

Upvotes: 0

Related Questions