简体   繁体   English

创建php文件以同步来自某些本地服务器的mysql数据

[英]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. 我开发了一个php应用程序,以从技术支持领域(TSF)便携式计算机(并不总是连接到Internet)和办公室的在线服务器获取输入。 My idea is to create a php file to sync (send and receive) latest data between office PC(online) and TSF laptop(offline). 我的想法是创建一个php文件,以在办公室PC(在线)和TSF笔记本电脑(离线)之间同步(发送和接收)最新数据。

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. 规则是每个TSF都应在一天的每一天同步,以将当天的报告发送到Office PC,并从Office PC获取最新数据,以便甚至可以脱机使用它们。

The problem is I don't know how to create that php file. 问题是我不知道如何创建该php文件。

Here the structure of my mysql database : 这是我的mysql数据库的结构:

Table merchant : merchant

id, name, address, phone, area, lastupdate

Table item : item

id, merchid, sn, sku, code, lastupdate

Table visit : 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... TSF只能编辑merchantitem表并添加visit表,办公室PC可以做任何事情...

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? 在每个表上,我都给lastupdate列,以便php sync脚本可以比较哪个是最新更新...但是我不知道如何使用php比较它...有人可以帮助我吗?

It's not something easy, you need to know a bit about PHP programming. 这并非易事,您需要对PHP编程有所了解。 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. 使用cron作业和简单的MySQL命令将所需的表提取到.sql文件。
  2. Send this file to the other PC via FTP, SCP or whatever you want 通过FTP,SCP或任何您想要的文件将此文件发送到另一台PC
  3. Again, via cron jobs and simple MySQL commands, update the tables in the current database with the file you just received. 同样,通过cron作业和简单的MySQL命令,用您刚收到的文件更新当前数据库中的表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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