I need a two way synchronization of tables if some thing insert in database1 's table then that thing automatically insert into another database which is database2's table. Could be possible in PHP? Is there any step by step procedure which can i follow for two different database which is stored on two different servers.
-
digitalocean.com/community/tutorials/…sumit– sumit2017-04-27 04:44:18 +00:00Commented Apr 27, 2017 at 4:44
-
@chris85: There are two different database i want if one table data is update in first database that data is updated in second database with another table and vice versaNisha Garg– Nisha Garg2017-04-27 04:51:13 +00:00Commented Apr 27, 2017 at 4:51
-
Oh so both are being written to, yea standard replication wouldn't work there.chris85– chris852017-04-27 04:52:59 +00:00Commented Apr 27, 2017 at 4:52
-
Is trigger or events help ?Nisha Garg– Nisha Garg2017-04-27 05:05:24 +00:00Commented Apr 27, 2017 at 5:05
1 Answer
it is "possible" (in general), but not immediate. for immediate action within the transaction you would need to do it on the DBMS with triggers and procedures. so have a look there.
doing it in PHP it may probably mess up things, but you can check on "db1" for a change since last check and process it to "db2". but if there is one transaction on "db1" and the next on "db1" follows fast, the data might not be in the state you wish to have.
or you just build the architecture differently as this sounds a bit odd to me. your description doesn't really tell why this would be done that way or even why there is need for two databases.