Welcome Guest, Not a member yet? Register   Sign In
Something messed up with foreach as $item
#1

[eluser]Lockzi[/eluser]
I'm trying to store some RSS feeds into a database of mine for fun...

Now I'm having a huge-a problem with $descr for some reason...

Code:
foreach ($this->simplepie->get_items() as $item) {
    $href    = $item->get_link();
    $title    = $item->get_title();
    $descr    = $item->get_description();
    
    
    if($this->rss_model->checkNewFeed($href))
    {
        die(var_dump($descr));
        $this->rss_model->insertNewFeed($feedName, $title, $href, $descr);
    }
}

That code produces the following:

string(0) ""

Sure... That make's it look like there's no description... But watch this!

Code:
foreach ($this->simplepie->get_items() as $item) {
    $href    = $item->get_link();
    $title    = $item->get_title();
    $descr    = $item->get_description();
        die(var_dump($descr));
            
    if($this->rss_model->checkNewFeed($href))
    {
        $this->rss_model->insertNewFeed($feedName, $title, $href, $descr);
    }
}

That code dumps this...

string(159) "The title of that feed item bla bla bla"

and I've checked this quite alot, and my conclusion is that whenever I use $this-> somewhere (*edit* between setting it and reading it *edit*) it looses the information in $descr.

Is that a bug?
Is there a way to get around it since I'd like to keep the checkNewFeed() code in the model to keep the database connections in the same place?

Regards,
Christoffer Wallenius


Messages In This Thread
Something messed up with foreach as $item - by El Forum - 09-13-2007, 05:05 PM
Something messed up with foreach as $item - by El Forum - 09-13-2007, 06:27 PM
Something messed up with foreach as $item - by El Forum - 09-14-2007, 01:08 AM
Something messed up with foreach as $item - by El Forum - 09-14-2007, 01:16 AM
Something messed up with foreach as $item - by El Forum - 09-14-2007, 01:23 AM
Something messed up with foreach as $item - by El Forum - 09-14-2007, 04:27 AM
Something messed up with foreach as $item - by El Forum - 09-14-2007, 04:31 AM
Something messed up with foreach as $item - by El Forum - 09-14-2007, 08:28 AM
Something messed up with foreach as $item - by El Forum - 09-14-2007, 10:30 AM
Something messed up with foreach as $item - by El Forum - 09-14-2007, 11:38 AM
Something messed up with foreach as $item - by El Forum - 09-14-2007, 12:41 PM
Something messed up with foreach as $item - by El Forum - 09-14-2007, 01:30 PM



Theme © iAndrew 2016 - Forum software by © MyBB