Ask questions about thinkphp development-php Tutorial

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.