简体   繁体   中英

Create php file to sync mysql data from some local server

I develop a php application to get input from a technical support field(TSF) laptop (which is not always connected to internet) and from an online server on office. My idea is to create a php file to sync (send and receive) latest data between office PC(online) and TSF laptop(offline).

The rule is that each TSF should sync every end of day to send that day report to office pc and get the latest data from office pc so they can be used even offline.

The problem is I don't know how to create that php file.

Here the structure of my mysql database :

Table merchant :

id, name, address, phone, area, lastupdate

Table item :

id, merchid, sn, sku, code, lastupdate

Table visit :

id, date, merchid, itemid, act, result, lastupdate

TSF only can edit merchant and item table and add visit table, office PC can do anything...

On each table i give lastupdate column so php sync script can compare which is the latest update...but i don't know how to compare it using php...can someone help me?

It's not something easy, you need to know a bit about PHP programming. Of course you can't expect anyone to do it for you here (you may pay someone to do it for you though).

However, why not trying a less elegant but more simple way:

  1. Use cron jobs and simple MySQL commands to extract the tables you want to an .sql file.
  2. Send this file to the other PC via FTP, SCP or whatever you want
  3. Again, via cron jobs and simple MySQL commands, update the tables in the current database with the file you just received.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM