hi,

Tracing my previous problem on why I cannot paginate with paginator, I
found out that the value I passed from controller to model is not
interpreted properly.

supposing clicking next button in paginator control, i got this url

http://myweb/index/index/page/2

In my  controller
============
$request = $this->getRequest();
$pgreq = $request->getParam('page');
=============

returns the expected value (2 in this case and I have verified this).

but I didn't understand why this values passes as function parameter
is not working inside the model function

so In my model function I have a code like this
==============
  public function fetchAllEntries($page=null)
  {
      $table = $this->getTable();
      $select = $table->select()->order('newsdate desc');
      $pgadapter = new Zend_Paginator_Adapter_DbTableSelect($select);
      $paginator = new Zend_Paginator($pgadapter);
      $paginator->setItemCountPerPage(5);
      if ($page == null)
      {
         $paginator->setCurrentPageNumber(1);
      }
      else
      {
         $paginator->setCurrentPageNumber($page);
      }

      return $paginator;
  }

  public function getTable()
  {
      if (null === $this->_table) {
          require_once APPLICATION_PATH . '/models/DbTable/NewsTable.php';
          $this->_table = new Model_DbTable_NewsTable;
      }
      return $this->_table;
  }

====================

the problem lies in
$paginator->setCurrentPageNumber($page);

(This is not working)


If I try to set he page manully like
$paginator->setCurrentPageNumber(3);

It is working



Can somebody tell me where is my blunder mistake?

Thanks


=======================
Registered Linux User #460714
Currently Using Fedora 8, 10
=======================

Reply via email to