Home Backend Development PHP Tutorial php实现同时发布,该如何解决

php实现同时发布,该如何解决

Jun 13, 2016 am 10:14 AM
commit insert start

php实现同时发布
我想做一个表单提交功能 把提交的数据同时发布到3个数据库里 请问代码怎么实现呀?

------解决方案--------------------
这是我的笨办法
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)
------解决方案--------------------
有两个方案 1、如果这三个库是三个服务器的话 设置主从同步数据库即可 
2、如果是同一个数据库的三个库,不妨做个简单的内部接口,源程序不变 post数据到这个接口去 让这个接口完成数据库的插入工作!
------解决方案--------------------

SQL code
acquire mutexcon1: START TRANSACTIONcon1: INSERTcon2: START TRANSACTIONcon2: INSERTcon3: START TRANSACTIONcon3: INSERTflag = 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<div class="clear">
                 
              
              
        
            </div>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What should I do if docker start cannot start? What should I do if docker start cannot start? Oct 21, 2022 pm 03:43 PM

Solution to docker start failure: 1. Check the running status, and then release the occupied memory through the "echo 3 &gt; /proc/sys/vm/drop_caches" command; 2. Use "$netstat -nltp|grep .. ." command to check whether the port has been occupied. If it is found to be occupied after going online, change it to an available port and restart.

What is the difference between insert ignore, insert and replace in mysql What is the difference between insert ignore, insert and replace in mysql May 29, 2023 pm 04:40 PM

The difference between insertignore, insert and replace instructions already exist or not. Example of insert error. Insertintonames(name,age)values("Xiao Ming", 23); insertignore ignores insertignoreintonames(name, age)values("Xiao Ming", 24); replace Replace and insert replaceintonames(name,age)values("Xiao Ming", 25); table requirements: PrimaryKey, or unique index result: the table id will be automatically incremented. Test code creates table

Use java's StringBuilder.insert() function to insert a string at the specified position Use java's StringBuilder.insert() function to insert a string at the specified position Jul 24, 2023 pm 09:37 PM

Use java's StringBuilder.insert() function to insert a string at a specified position. StringBuilder is a class in Java used to handle variable strings. It provides a variety of methods to operate strings. The insert() function is used to insert strings at specified positions. One of the common methods of positionally inserting strings. In this article, we will introduce how to use the insert() function to insert a string at a specified position and give corresponding code examples. insert()

What is the difference between slow commit in MySQL slow query and slow transaction in binlog? What is the difference between slow commit in MySQL slow query and slow transaction in binlog? May 30, 2023 am 08:07 AM

1. Source of the problem When analyzing performance problems, slow queries and binlog slow transactions are commonly used methods. Recently, I was analyzing a slow query and found that it contained a large number of commit statements that were slow, but the matching could not be completed when analyzing the binlog slow transactions. For example, there may be 1,000 commit statements during this period, but there may be only 100 slow transactions. This is too big a difference, so why does this phenomenon occur? 2. The respective determination methods for slow transactions are usually as follows for an explicitly submitted (insert) transaction: GTID_LOG_EVENT and XID_EVENT are the time when the command ‘COMMIT’ is initiated.

How to add, edit and delete table rows in jQuery? How to add, edit and delete table rows in jQuery? Sep 05, 2023 pm 09:49 PM

In today's era of web development, effective and efficient table management has become very important, especially when dealing with data-heavy web applications. The ability to dynamically add, edit, and delete rows from a table can significantly enhance the user experience and make applications more interactive. An effective way to achieve this is to leverage the power of jQuery. jQuery provides many features to help developers perform operations. Table rows A table row is a collection of interrelated data, represented by elements in HTML. It is used to group together cells (represented by elements) in a table. Each element is used to define a row in the table, and for multi-attribute tables, it usually contains one or more elements. Syntax$(selector).append(co

What to do if node start reports an error What to do if node start reports an error Dec 29, 2022 pm 01:55 PM

Solution to node start error: 1. Execute "node xx.js" directly in the terminal; 2. Add start startup item "scripts": {"test": "echo \"Error: no test specified\" && exit 1 ","start":"node service.js"}"; 3. Re-execute "npm start".

insert statement insert statement Sep 15, 2023 pm 01:30 PM

The basic syntax of the insert statement is "INSERT INTO table name (column 1, column 2, column 3, ...), VALUES (value 1, value 2, value 3, ...);", "table name" is to be inserted The name of the data table. "Column 1", "Column 2", "Column 3", etc. are the names of the columns in the table where data is to be inserted. "Value 1", "Value 2", "Value 3", etc. are the names of the columns to be inserted. data value.

How to undo a commit in git How to undo a commit in git Jul 24, 2023 pm 01:33 PM

How to undo a commit submitted by git: 1. Modify the content of the last commit. If you find that there is an error in the last commit, you can use the "git commit --amend" command to modify it; 2. Undo the changes of a commit, If you need to completely undo a commit and its corresponding changes, you can use the "git revert" command; 3. If you need to completely roll back to the state before a commit, you can use the "git reset" command.

See all articles