I would like to ask you some questions about thinkphp development. I just got started with the MVC development mode. when thinkphp is used for development, the forms submitted by the user, is form verification on the c layer or the m layer?
Reply to discussion (solution)
Read the development manual carefully.
Put it in C.
Read the manual
Thinkphp built-in model verification
If you find it inconvenient, you can receive parameters for manual verification in C.
The model layer is verified when it is stored in the database.
If the database is not imported into the database, do you verify it on the C layer? isn't there an I function?
It is better to encapsulate the data in the M layer. check the required fields and data validity before receiving the data.
For example, the user name and password are required, and the number of digits is greater than 6.
If the operation is successful, true is returned. if the operation fails, an error string is returned. then, the error is printed at layer C based on the situation $ this-> error ().
The M-layer interface can be called by multiple pages in the C-layer.
Cm.
M layer, automatic verification.
Thank you. the parameter source of the M-layer function uses the C-layer function. in this way, the M-layer method can be reused. it is better to verify the data on the M-layer.