Reputation: 3484
I am using 3 MySQL databases simultaneously. I need to insert 3 rows into 3 different databases.
Is it possible to use one transaction to accomplish this? If not, what would be an alternative method?
Upvotes: 1
Views: 117
Reputation: 163282
The databases are separate. You cannot use a transaction across them... that is impossible.
All you can do is perform 3 separate INSERTs.
Now, I suppose you could start a transaction on each, insert 3 rows, then end transaction on each, but this may not achieve your ultimate goal, depending on what it is.
Edit: I may stand corrected. See information here: http://dev.mysql.com/doc/refman/5.1/en/xa.html
Upvotes: 2
Reputation: 5032
PHP does not provide anything that I know of by way of distributed transaction management. You will need to handle this manually...that is if one of the insertions fail you will need to rollback in the other dbs.
If you are not tied to using php, Java EE has support for this. JTA
Upvotes: 0