Using Xml For Database

In my application using xml for database insertion. I want to refresh the xml content in every 30 min automatically and update the database content. When it performing?


If your hosting allows you to use cron jobs, you can do that by calling an Yii console command. Here’s a topic about that.

I didn’t clear the concept…

I want to post a xml url and save it in the database. and refresh the database content at a particular time period.

Still not too clear. Can you go into more detail about exactly what you’re trying to do?

In my application have master table for storing details of users. The data for user table selected from xml url. Now want to store the data of user from xml and refresh the user data in a particular time interval when xml url data have any updation.

Fetching the xml file and doing the job still have to be done with a cron job.

For manipulating an xml document, you can use simpleXML php native function (libxml have to be installed on your web host).

XPath is also really cool for querying xml documents.

I assume that you have already an User model declared.

If your user xml data set contains an "updated_at" field for each user then it should be quiet easy:

1/ get the last updated_at date in your User database

2/ parse the xml with this updated_at as condition for getting the modified users

3/ in a loop, update your User database with results fetched from 2/