Skip to content
lobostome edited this page Jul 7, 2013 · 3 revisions

The library provides a convenient interface to iterate over the result pages.

Here is a foreach example that will go over ALL results and output them.

$params = array('query'     => 'committee of the whole',
                'chamber'   => 'house');

try {
    $fb->floor_updates->setParams($params);
    foreach ($fb->floor_updates as $page) {
        var_dump($page);
    }
} catch (\Exception $e) {
    echo $e->getMessage();
}

Here is another way to do the above using while.

$params = array('query'     => 'committee of the whole',
                'chamber'   => 'house');

try {
    $fb->floor_updates->setParams($params);
    $it = $fb->floor_updates->getIterator();
    while($it->valid()) {
        var_dump($it->current());
        $it->next(); // How ugly that is..., but necessary
    }
} catch (\Exception $e) {
    echo $e->getMessage();
}

Note: Due to the specifics of each provider and the meta data they provide (or the lack of it), there are variations in the above examples. Please check the individual provider's documentation for more details.

Clone this wiki locally