I'm using simplepie. I want to store the rss feeds items into mysql database. I've been parsing every RSS items into $link,$title,$date,$content. But simplepie get the rss feeds from its resource need few seconds and insert into just one moment, that cause it always stores first few lows of RSS items, not all of them. How to delay INSERT time that can store all of the rss items into mysql database?TXS
PHP is a syncronous language. That means it performs step 1, and then step 2, and then step 3. It is very difficult to instruct it to do step 1, 2 and 3 all at the same time. What you're suggesting doesn't really mesh with the way php works. Fetch feed Parse feed Insert data You can't even start parsing until the feed is completely read. You can insert while you're parsing with a loop, but the feed must me fully fetched. I would bet that there is a problem with the coding and not with the script needing more time to get the rss feed.
Thanks, maybe you are right "there is a problem with the coding". I changed another rss feed url, it has 20 feeds items. I run my script first time, it inserted 7 items into database. Then when I empty the database and run the script second time, it inserted 10 items into database. the insert number is not stable, but it always can not insert all of them. I can not check the wrong problem out.
Hi, I added echo behind insert for check, then compared the results. I find something. When the article has ' or " ,I can not find them in the database. The quotation mark made the mistake. Maybe I should add some: $str = preg_replace('/\'/', "\'", $str); $str = preg_replace('/\"/', '\"', $str); Thanks, I'm continuing my test. Late I will tell you results.