On Tue, Feb 10, 2009 at 7:31 PM, PHPScriptor <[email protected]> wrote:
>
> I don't know if this will answer your question, but this is how I do it:
>
> The paginator is set in the controller. I think you could do it in the
> model, but that would make things a lot complicater.
> Where to define your select, where,... 99% I do in the controller. 'Cause if
> not, you need to pass all your values to the model.


Thank you this is what I exactly want to know about how things get
orchestrated. This time you read my mind. :-)

> $NewsModel      = new News_NewsModel();
> $select         = $NewsModel->select();
> $select->order('newsdate DESC');
> $select->where('id>5');
> $news           = $NewsModel->fetchAll($select)->toArray();
>
> $paginator = Zend_Paginator::factory($news);
> $paginator->setCurrentPageNumber($this->_getParam('page'));
> $paginator->setItemCountPerPage(5);
> $paginator->setPageRange(10);
>
> $this->view->news       = $paginator;
>
> The 'order' and 'where' can also be done in a model-function. But why
> creating an extra function just for 2 conditions. So I do it in my
> controller.

Thanks for the example too. But small question (unclear to me).
do I need to fetch all before feeding to paginator? or I will feed the
select itself?

what I understood from documentation is if used with Zend_db_select it
will just fetch the necessary rows only. So what is the advantages and
disadvantages in this two approach? or what are the best practices
(blah....)

This is what I think (please correct me if I am wrong):
======================================
1. If fetchall is used, we don't need to requery the db; just move
back and forth between already fetch data.So new entries after
fetchall operation will not be reflected in the serach result.

2. If we feed select to paginator, it will requery db everytime we
move back and forth plus it is possible to see the new entries made
after query when we go back (i.e, what I saw in first page can move to
second page after a while when I come back again to first page)
======================================

Is this true?

I am asking about this from the performance aspect

If one approach has advantage over another, can you tell me what are they?

I like your explanation. Its straight to the point.

Plus can you give me some info on "Zend_Controller_Router_Interface"
about how it works.

Thanks again.

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

Reply via email to