cotroller function:
function getFeed() {
$content = file_get_contents($this->input->post('rss_url'));
$x = new SimpleXmlElement($content);
foreach($x->channel->item as $entry) {
$feeds[] = array(
'title' => (string)$entry->title,
'link' => (string)$entry->link,
'username' => $this->session->userdata('username'),
'rss_source' => $this->input->post('rss_url')
);
}
$this->load->model('membership_model');
$this->membership_model->insert_feeds($feeds);
}
model:
function insert_feeds($feeds_data)
{
$this->db->insert_batch('feeds',$feeds_data);
}
I have a form where I put a feed url.
This feed url is stored into a database. The database looks like this:
- id (which is the primary key)
- title (title of every item from the xml file)
- link (of every item from xml file)
- username (the username who put the feed url into the form)
- rss_source (the url that the user puts into the form).
What I want to do is to make a cron job who insert every 2 days new rows in the database.
I must make another controller function like the getfeed function, who is getting the contents from the database rss sources and put them in new rows with the same model function?