CodeIgniter Forums
what's wrong with this method? - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: what's wrong with this method? (/showthread.php?tid=31454)

what's wrong with this method? - El Forum - 06-19-2010

Hello ,
what's wrong with this method :
/*database :
    table : rss
    id : int(auto)
    link : varchar(255)
    link:varchar(255) // the link of the details in the website
    content:text // the description of the rss
    cat:INT // the category id of the entry
    function index(){
    //get the rss links and them category like : , ,
    $rss = $this->Mrss->get();
    //extract the array
    foreach($rss->result() as $rss){
    $cat = $rss->cat;
    $url = $rss->url;
    $this->load->library('RSSParser', array('url' => $url, 'life' => 2));
    //a loop to get the rss from each link
    $datas = $this->rssparser->getFeed(40);
      foreach ($datas as $item) {
      $word = array("\\","/","\"","'");
      $data['title'] = htmlspecialchars(str_replace($word,"-",$item['title'])) ;
      $data['content'] = $item['description'] ;
      $data['link'] = $item['link'] ;
      $data['cat'] = $cat;
//check if the entry was already added and then save it to the database

the problem that when i add 5 or 6 link the method don't grab all the feed just one or two from one category and it ignore all other category .
i use rssparser .

what's wrong with this method? - El Forum - 06-20-2010

Could it be that your script is timing out? I see you have set a long time, but if this is not on your server, or you are unable to change the setting in php.ini. If you are unable to set it in php.ini, it may not matter what value you plugin to your script. How about setting up a timer in your loop to see how long it is executing until it stops?

what's wrong with this method? - El Forum - 06-20-2010

Maybe because your loading the RSS library multiple times in your
foreach loop?


what's wrong with this method? - El Forum - 06-21-2010

pickupman , the problem is not from the timer ..i test in localhost and nothing was change.
InsiteFX its not the problem of loading , the problem is that i have to unset the variables of the rss library i think because it load the sam rss in every loop ??

what's wrong with this method? - El Forum - 06-21-2010

Since, it's hard to know what's going on the rest of the code, the only thing I could suggest is start dumping vars, and see if you are always getting the results from your DB.
What happens when you don't use your rss library? Have you tried the Simplepie library? RSS should be pretty straightforward. Make sure you are first fetching your data from the feeds first, and keep adding stuff back into parsing until you get your results.