• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
what's wrong with this method?

#1
[eluser]7amza[/eluser]
Hello ,
what's wrong with this method :
Code:
/*database :
    table : rss
    id : int(auto)
    link : varchar(255)
    title:varchar(255)
    table:news
    id:int(auto)
    title:varchar(255)
    date:varchar(50)
    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(){
    set_time_limit(2160000000);
    //get the rss links and them category like : http://google.com/rss.xml , http://yahoo.com/rss.xml , http://msn.com/rss.xml
    $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
          if($this->Mnew->getbylink($data['link'])==FALSE){
      $this->Mnew->add($data);
                }
            }
        }
    }

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 .

#2
[eluser]pickupman[/eluser]
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?

#3
[eluser]InsiteFX[/eluser]
Maybe because your loading the RSS library multiple times in your
foreach loop?

InsiteFX

#4
[eluser]7amza[/eluser]
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 ??

#5
[eluser]pickupman[/eluser]
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.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.