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 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝