How to solve the problem of simultaneous php implementation and release

Source: Internet
Author: User
Php implementation and release at the same time I want to make a form submission function to publish the submitted data to three databases at the same time. how can I implement the code ?, This is my stupid method. the implementation of INSERTINTOTABLE1 (A, B, C) VALUES ($ A, $ B, $ C) INSERTINTOTABLE2 (A, B, C) VALUES (php is released at the same time.
I want to create a form submission function to publish the submitted data to three databases at the same time. how can I implement the code?

------ Solution --------------------
This is my dummies.
Insert into TABLE1 (A, B, C) VALUES ($ A, $ B, $ C)
Insert into TABLE2 (A, B, C) VALUES ($ A, $ B, $ C)
Insert into TABLE3 (A, B, C) VALUES ($ A, $ B, $ C)
------ Solution --------------------
There are two solutions 1. if the three databases are three servers, you can set the master-slave synchronization database.
2. if it is three databases of the same database, you may wish to make a simple internal interface. the Source program will not post data to this interface to let this interface complete database insertion!
------ Solution --------------------
SQL code
Acquire mutexcon1: START TRANSACTIONcon1: INSERTcon2: START TRANSACTIONcon2: INSERTcon3: START TRANSACTIONcon3: rows = con1 insert OK & con2 insert OK & con3 insert okif (flag) {con1: COMMIT con2: COMMIT con3: COMMIT} else {con1: ROLLBACK con2: ROLLBACK con3: ROLLBACK} release mutex

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.