You cannot create a model for every table on ThinkPHP.

Source: Internet
Author: User
About how to create a model in ThinkPHP, you can not create a model for each table. We need to create a model for each table according to our previous method. For example, to design four tables for each table, we need to create models separately. you can add, delete, modify, and query a virtual model... you cannot create a model for every table on ThinkPHP.

According to our previous method, we need to create a model for each table. For example, we have designed four tables and each table. We need to create a model for addition, deletion, modification, and query.

I can see that there is a virtual model that can be used to create a virtual model. This is my User. I only need to create a User class and direct D (User). However, the rational virtual model should not operate on the database. for example, automatic verification cannot be performed. is there any way to combine the operations of the four models to be created into a virtual model?

Reply content:

You cannot create a model for every table on ThinkPHP.

According to our previous method, we need to create a model for each table. For example, we have designed four tables and each table. We need to create a model for addition, deletion, modification, and query.

I can see that there is a virtual model that can be used to create a virtual model. This is my User. I only need to create a User class and direct D (User). However, the rational virtual model should not operate on the database. for example, automatic verification cannot be performed. is there any way to combine the operations of the four models to be created into a virtual model?

Search to see if you want to associate the Model

You can create a model as you like. For example, you can create an AbcModel. class. php file. You can write the specific method in it. It's the method you imagined. You can call it directly with D (). You can only calculate what you want to do automatically. In fact, it seems that the actual work is rarely used, after all, I think automatic verification is inefficient...

Yes. There is no absolute relationship between the model and the table!

The big M method is only used for data CURD. There is actually no class for instantiation. Official documents: http://document.thinkphp1.cn/manual_3_2.html#model_instance

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.