lundi 7 septembre 2020

PHPMYADMIN | How could we sync two tables in two different MySQL databases (Within same server)?

  • I have two MySQL databases site1 & site2[Both reside in the same server].

  • I have a table named users in both the above databases(Exact same structure in both site1 & site2). The structure is as shown below :

    enter image description here

How it works :

So site1 & site2 would have users registering themselves to the database(for some use-cases) via a mobile application. So a user download the mobile app -> depending on the user location, they're going to fall into either site1 or site2 -> User register themselves & this is how new row entries get generated in the users table.

What am i trying to achieve ?

Since the same user may come to both sites occasionally, site1 or site2 should have the users table synchronized for all columns. So based on unique phone numbers(phone), the rows of users table in both site1 & site2 should always be synchronized. How can we achieve this ?? I know that triggers is an option, but I'd appreciate a sample code for the format to be used..or any hints would be much appreciated. Now sure how helpful an event is for this use-case. Can someone please assist ?

PHP framework used is Laravel.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire