In php, how to write a model to operate multiple tables?

Source: Internet
Author: User
A common example is that when a mall places an order, there will be 3 to 5 orders or the MVC mode. In this example, a template is created for each table, then, when the order is placed, call each model or write only one model for the order step, and then modify each table. Maybe this... for example, when a mall places an order, there are 3 to 5 orders or

In the MVC mode, take the order as an example,

Is to create a template for each table, and then call each model when placing an order

Or write only one model for the order step, and then modify the tables.

This problem may be a bit low-level, but there is no way. I am not capable of abstracting models.

Reply content:

For example, when a mall places an order, there are 3 to 5 orders or

In the MVC mode, take the order as an example,

Is to create a template for each table, and then call each model when placing an order

Or write only one model for the order step, and then modify the tables.

This problem may be a bit low-level, but there is no way. I am not capable of abstracting models.

At this time, it is best not to operate on the data model, but on the logical model.
That is to say, a Data Model is a table corresponding to a Model. Insert a Logic Model between the data Model and the Controller to perform logical operations (such as placing orders) through the logical Model (which operates multiple data models ).
This ensures that the overall architecture is clear.

Check out my answer.

Https://segmentfault.com/q/1010000003849810/a-1020000003851204

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.