dsz1966 2011-06-04 20:44
浏览 63
已采纳

使用外部XML更新/填充mysql数据库的有效方法

I am working on a small app that utilizes a game API, unfortunately the API is not the fastest in the universe. It also only outputs large XML files.

I want to grab one of these files and place it directly into a database, this way it is not being queried from their servers each time a user needs to update something. Instead its querying my local database. I would grab it via a cron job every few hours, thus it shouldn't affect performance.

My question is: What is the most efficient way for me to grab the XML file from their server and update my database with their updated version? [As a note, I am using only PHP for this and want to keep it that way.

Thank you for your assistance!

  • 写回答

1条回答 默认 最新

  • dongou2019 2011-06-04 20:59
    关注

    I would parse the XML-file from their server using something like simpleXML.

    I guess the XML-files have elements which are basically the same with other values? In this case, you'll want to create a PreparedStatement and bind new parameters for every entry. This is the most performant way to do this.

    But if you care mostly about performance, PHP isn't the way to go. You could use Java (for example) to parse the XML-File and write the entry's in your Database. With which language you access the filled database is of no concern.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?