In PHP, if you want to manipulate multiple tables, how does the model write

Source: Internet
Author: User
Common example, when placing an order in a shopping mall, there will be 3 to 5 or more tables associated with the order.

In the MVC pattern, in the case of a single

is to create a template for each table, and then call each model when you place an order

or the next step. Write only one model, then modify each table

Maybe the problem is a little low, but there is no way, I am not enough of the model abstraction ability.

Reply content:

Common example, when placing an order in a shopping mall, there will be 3 to 5 or more tables associated with the order.

In the MVC pattern, in the case of a single

is to create a template for each table, and then call each model when you place an order

or the next step. Write only one model, then modify each table

Maybe the problem is a little low, but there is no way, I am not enough of the model abstraction ability.

It is better not to manipulate the data model at this time, but to operate on the logical model.
In other words, the data model is still a model corresponding to a table. In the data model and controller, and then insert a logical model (logic model), through the logical model (logical models to manipulate multiple data models) to complete a number of logical operations (such as single, etc.).
This will ensure the clarity of the overall architecture.

Look at my answer.

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

  • Related Article

    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.