We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

NativeArray No Longer Works in Phalcon v4.0

Phalcon v4.0 removed "getPaginate()" and now paginator no longer works!

Here is code example used;


    use Phalcon\Paginator\Adapter\NativeArray;

        $array = [
            1 => 'one',
            2 => 'two',
            3 => 'three',
            4 => 'four',
            5 => 'five',
            6 => 'six',
            7 => 'seven',
            8 => 'eight',
            9 => 'nine',
            10 => 'ten',
        ];

        $test = new NativeArray([
            'data' => $array,
            'limit' => 1,
            'page' => 1,
        ]);

    print_r($test);

This loads all 10 items instead of 1.

Phalcon\Paginator\Adapter\NativeArray Object
(
    [_limitRows:protected] => 1
    [_page:protected] => 0
    [_repository:protected] => 
    [_config:protected] => Array
        (
            [page] => 
            [limit] => 1
            [data] => Array
                (
                    [1] => one
                    [2] => two
                    [3] => three
                    [4] => four
                    [5] => five
                    [6] => six
                    [7] => seven
                    [8] => eight
                    [9] => nine
                    [10] => ten
                )

        )

)

What am I missing here? Thank You!



1.6k
Accepted
answer
edited Jan '19

Big thank you to GitHub user "CameronHall" for pointing me in the right direction. All I had to do is change "getPaginate()" to simply "paginate()" and everything works as it used to. Thank you everyone who contenue working on Phalcon v4.0+ this is the best framework, and I used many others so I know ^_^