What exactly is the Model for in a PHP application?

Asked

Viewed 381 times

-2

Can a Model class be used to store the columns of a database table? Or does she just store the methods for the business rule? If it does not store the columns, what part of the application is responsible for storing the columns of a table?

  • https://answall.com/questions/55486/o-que%C3%A9-mvcmodel-view-controller

  • Read my question, the title was just to call attention, the links you provided do not help me to answer my specific question, I want to know what is in the body of the question.

1 answer

-3

The model is the part that has to have the logic of data model, independent if it is an SQL database , Nosql, Graph etc.

The model should have no business rules, this belongs to the controller layer, in the simplest case it serves as a representation of the data model in the database, so let’s say that we have the Products Table containing the Id columns,Name,Price a model of this table would be the Productsmodel class with properties Id,Name,Price.

In an ideal world you could simply change form of persistence (SQL, Nosql, Graph , TXT file) and this model could work normally - but in general this is not so.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.