Welcome Guest, Not a member yet? Register   Sign In
[5.0] Model::paginate()
#1

Idea!

1. Model::paginate() -> Model::paginate(): Pager

2. class Pager implements PagerInterface, IteratorAggregate

3. Pager::setCollection(array $collection): self

4. Pager::getIteratior(): ArrayIterator

result
PHP Code:
$posts = (new Posts)->paginate(10);
$users = (new Users)->paginate(10);

foreach (
$posts as $post) {}

$posts->links(); // links for posts
$users->links(); // links for users 

No need to specify groups and pass a separate instance of the Pager class
Reply
#2

Looks good to me.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

It looks better than now.
Reply
#4

I would love to see a lot more iterators in the framework, especially in the middle layer between the database and everything else. We are doing way too much heavy preloading instead of yielding, like this is 2005 :O
Reply




Theme © iAndrew 2016 - Forum software by © MyBB