douyabu1528 2013-10-14 10:30
浏览 61
已采纳

将mysql DB与xml文件同步

  1. I have wordpress page (along with mysql db with wp tables.
  2. I have custom table in DB named "custom_table"

What I need is to add functionality to upload xml file on wordpress page and then sync my custom_table with this xml so the table reflects xml file.

XML file size is now ~6MB but I guess it might grow in the future. During syncing custom_table has to be intact - I mean that changes to the table during syncing have to be atomic - all or nothing.

It is a good idea to do this in normal php script or I should better make some background job for this stuff? For example upload xml file to server and then run in background a job which will parse xml file and put to DB?

  • 写回答

1条回答 默认 最新

  • duanjuduo4573 2013-10-14 10:55
    关注

    6MB is a lot when you are dealing with a slow internet connection and with a script that has a chance of timing out.

    I see 3 issues that you are trying to solve here -

    1. Long running processes - background jobs are perfect for this. You can cut off the user session using pcnt_fork() or by just closing the session and then continuing the processing. Ensure that your max_execution time is set to 0 or sufficiently long.
    2. Atomicity - ACID is a main feature of the InnoDB format. Create your table as InnoDB instead of MyISAM.
    3. Completion - you will need to keep track of success/failure. Background jobs are difficult to debug. As you are working with Wordpress, I'm assuming that you are on a shared host? You can try adding statements at appropriate locations in your code that will send you an email or use system logging if that's available to you. Another way would be to have a separate table for logs.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能