Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Pager.php Pear did not work in fuelphp ?

  •  //create dummy array of data
    $myData = array();
    for ($i=0; $i<200; $i++) {
        $myData[] = $i;

    $params = array(
        'itemData' => $myData,
        'perPage' => 10,
        'delta' => 8,             // for 'Jumping'-style a lower number is better
        'append' => true,
        //'separator' => ' | ',
        'clearIfVoid' => false,
        'urlVar' => 'entrant',
        'useSessions' => true,
        'closeSession' => true,
        //'mode'  => 'Sliding',    //try switching modes
        'mode'  => 'Jumping',

    $pager =  & Pager::factory($params);
    $page_data = $pager->getPageData();
    $links = $pager->getLinks();

    I am get the error like this 

    Fuel\Core\PhpErrorException [ Runtime Notice ]: Non-static method Pager::factory() should not be called statically, assuming $this from incompatible context

  • How old is the framework you're using? We don't use factory() since I think 1.1?
  • my fuelphp version is 1.6 
  • The Fuel framework doesn't have a class called Pager, so I don't know what that is.

    It does have a class called Pagination. From the methods used I assume Pager is some sort of extension for it, but written for a very old version of the framework (given the fact it uses 'factory'). So changes are you are running into some sort of version incompatibility.
  • here I mean Pager.php from pear pagination class

    I am using that because I want to create paging from my array result.
  • Then you're perhaps in the wrong forum.

    But the message is very clear: "Non-static method Pager::factory() should not be called statically, assuming $this from incompatible context"

    It's not a static class, and factory() is not defined as a static method, so you can't call it statically, you need an object you can call it on.
  • Hi Harron

    I am agree with you that message is so clear, but when I am try to change using $this context , I got the errors to using static method, that was so weird

    this my code

    $pager =  new Pager();

    after run 

    Fuel\Core\PhpErrorException [ User Error ]: Pager constructor is deprecated. You must use the "Pager::factory($params)" method instead of "new Pager($params)"

    I don't know that happend from framework or my php version.
  • The problem of this message is that this Pager class is a piece of antique PHP4 rubbish...

    In PHP4, you had to define a method with the same name as the class, and this method was called as a constructor. In PHP5, your constructor method has to be called __construct.

    Also, late PHP4 and early PHP5 didn't care about static and non-static, so you didn't get the warning. But in current PHP versions, you no longer call non-static method statically.
  • ok , thanks you for the information, maybe i should choice another way for array pagination.
  • Why not use the frameworks own Pagination class?
  • I think I got problem in query params  pagination ?dostull=...&do_another=...
    for new version supported that params in pagination.

    I just fixed by upgrade my version framework.and using pagination class on framework.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion