On Tue, Feb 10, 2009 at 11:58 PM, keith Pope <mute.p...@googlemail.com> wrote: > Heres what I do, this is within a model resource Model has Resource -> > Zend_Db_Table. > > public function getProductsByCategory($categoryId, $paged=null, > $order=null) > { > $select = $this->select(); > $select->from('product') > ->where("categoryId IN(?)", $categoryId); > > if (true === is_array($order)) { > $select->order($order); > } > > if (false !== $paged) { > $adapter = new > Zend_Paginator_Adapter_DbTableSelect($select); > $count = clone $select; > $count->reset(Zend_Db_Select::COLUMNS); > $count->reset(Zend_Db_Select::FROM); > $count->from('product', new Zend_Db_Expr('COUNT(*) AS > `zend_paginator_row_count`')); > $adapter->setRowCount($count); > > $paginator = new Zend_Paginator($adapter); > $paginator->setItemCountPerPage(5) > ->setCurrentPageNumber((int) $paged); > return $paginator; > } > > return $this->fetchAll($select, array('catIds' => $categoryId)); > } > > Full code here http://code.google.com/p/zendframeworkstorefront/
Thanks for the tips. I got some idea from yours and my implementation is something like this: =============== 1. Controller gets the form parameters through getValues() and pass everything to Model. 2. Model (which have access to DBTable) will dynamically generate query based on user's criteria and initialize the paginator and returns to Controller. 3. Controller then assign the returned paginator to view. ============= so far I was able to display the result but I am confused over where the paginator control's phtml file goes. Supposing my paginator control's filename is 'mypaginator.phtml'. Where does this file reside? my view script for pagination control =================================== <div id="pgcontrol"> <?= $this->paginationControl($this->mypaginator, 'Sliding', 'mypaginator.phtml'); ?> </div> ================================== I am getting errors in place of paginator control. in the same place as the view script? ======= views scripts index index.phtml mypagintor.phtml ======== using this I got file not found error. OR resides in separate directory? ======== views scripts mypaginator index.phtml ============ using this I got include error. OR in the public directory? Need some suggestions Thanks -- ======================= Registered Linux User #460714 Currently Using Fedora 8, 10 =======================