Sid
Sid

Reputation: 856

Update a database on server from multiple local databases

I am building a web-based ERP application for the retail industry using PHP and MySQL. I am going to have different local databases and one on the server(same structure). What I plan to do is run this app in localhost in different stores and at the end of the day update the database on the server from different localhosts in different stores.

Remember, I would like to update the database on the server based on the sequence queries run in different databases.

Can anyone please help me with this?

Thank you.

Upvotes: 0

Views: 489

Answers (2)

befox
befox

Reputation: 206

You may have to log every insert/update/delete sql requests in a daily file with a timestamp of your request on local databases.

Example :

 2012-03-13 09:15:00 INSERT INTO...
 2012-03-13 09:15:02 UPDATE MYTABLE SET...
 2012-03-13 09:15:02 DELETE FROM...
 ...

Then send your log files daily on main server, merge all files, sort them to keep execution order and read new file to execute request on main database.

However, it's a curious way to do thing on ERP application. A product stock information can't be merged, it's a common information, be careful with this kind of data.

You can't use autoincrement with this process, this will cause duplicate key on some request or update requests on bad records.

Upvotes: 0

DACrosby
DACrosby

Reputation: 11430

Perhaps link to your main database from the localhost sites to begin with? No need to update at the end of the day, every change that's made to the database is simply made to the database with no "middle men", so to speak. If you need the local databases separate, run the queries on both at once?

Note: I'm unfamiliar with how an ERP application works, so forgive me if I'm way off base here.

Upvotes: 1

Related Questions