Do normal CRUD operations need to go through the business layer? The actual situation is that the create, delete, update, and find methods provided by ActiveRecord can be used to deal with common CRUD operations that need to go through the business layer?
The actual situation is that the create, delete, update, and find methods provided by Active Record can be used directly.
Reply content:
Do normal CRUD operations need to go through the business layer?
The actual situation is that the create, delete, update, and find methods provided by Active Record can be used directly.
Generally, CURD performs
S layer to do some complex things
The CRUD of a single object is implemented in DAO, and the Service layer calls these CRUD methods.
The common practice of Rails does not require the business layer.
For details, refer to the description of InitPHP framework layering:
Http://initphp.com/3_2.htm
MVC layering is a common and reasonable method for development.
The MVC layer divides the Web into three layers: model layer, control layer, and view layer.
The MVC layer separates PHP code from HTML to make the project more clean and clear.
InitPHP uses the DSCV hierarchy by default, and also supports MVC hierarchy. DSCV divides the M layer of MVC into DAO and Service layers.
To use MVC layering, you only need to directly call the InitPHP: getDao () Class in the Controller.
DSCV layers: Dao (data layer), Service (business Service layer), Controller (control layer), View (View layer)
The most important feature of DSCV layering is to separate the Model layer Model of MVC into the Dao data layer and Service layer.
The advantage of DSCV layering is to clarify the responsibilities of each layer. The data layer focuses more on Data Operations (SQL operations and cache operations), and the business service layer focuses more on providing common function interfaces for the control layer.
A Service is generally intended for businesses. For example, a user-class UserService provides interfaces such as user registration and user information modification. The Service can be called by the Controller.
The Service obtains data through Dao. A complex Service corresponds to multiple Dao.