开发者

Efficient way to update/populate a mysql database with external XML

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 qu开发者_JAVA技巧erying 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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜