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/

2009/2/10 Deepak Shrestha <[email protected]>:
> On Tue, Feb 10, 2009 at 9:15 PM, PHPScriptor <[email protected]> wrote:
>
>> You always come back in your controller. The zend paginator add's the param
>> 'page' in the url.
>> So you always do a requery. (if that's what you wanted to say).
>>
>> http://localhost/news become http://localhost/news/page/1
>
> Thanks for the clarification.
>
> What I mean is if we do fetchAll(), the result is already in the
> memory (static) and no matter how paginator access it, it will show
> the data already in memory (no requery to db but only get  another
> part from already fetched query).
>
> While if we feed the select() (accroding to documentation in NOTE
> section http://framework.zend.com/manual/en/zend.paginator.usage.html),
> it will requery db each time page changes and it is possible to see
> the changes in query result over time.
>
> Anyway I now know few concepts to get started with. By the way I found
> a tutorial 
> http://teethgrinder.co.uk/perm.php?a=Zend-Framework-MySQL-DB-Pagination-Tutorial
> while following the previous post on similar topic but didn't make
> sense till now.  I will have re-look and try something. I won't know
> until I will try.
>
> Anyway thanks and Regards!
>
> --
> =======================
> Registered Linux User #460714
> Currently Using Fedora 8, 10
> =======================
>



-- 
----------------------------------------------------------------------
[MuTe]
----------------------------------------------------------------------

Reply via email to