What is the significance of one model per table in the PHP framework

in many frameworks, each table corresponds to a model,. We usually add a service layer in the MVC to deal with business logic. Why not directly manipulate the db class in the service layer

What is the advantage of the

framework doing this (one model per table)
Thank you

Sep.01,2021

now let's talk about three popular frameworks, foreign Laravel and Symfony and or internal ThinkPHP 5. There is no so-called Service layer in these three. Service is written by developers themselves. The main meaning of Model in these three frameworks is to define the data relationship, in other words, to define the relationship between the table and the table. For example, in Laravel, a user is a User model, corresponding to the users table, and a Post model corresponding to the posts table. In the posts table, there is a users.id field corresponding to the user_id field. So you can use the first method in the User model:

  

is just plain and simple. Try not to directly manipulate the table, but the encapsulation method, so that it is more controllable

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b377dc-2b816.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b377dc-2b816.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?