2010年7月31日星期六

Re: [fw-db] Need help with Pagination

Controller Action:

public function trypaginatorAction(){
{

$GETDATA = new Model_Managers_Paginator();
$getdata = $GETDATA->simplepaginator();
//require_once 'Zend_Paginator_Adapter_Interface.php';
//require_once 'Zend/Db.php';
//require_once 'Zend/Db/Select.php';

// require_once 'Zend_Paginator_Adapter_DbSelect.php';

$paginator = new Zend_Paginator(new Zend_Paginator_Adaptor_DbSelect($getdata));
$paginator->setItemCountPerPage(25)
->setCurrentPageNumber($this->_getParam('page',1));

$this->view->paginator = $paginator;

}





View:

<?php
foreach($this->paginator as $paginator){
echo $paginator['DOCUMENT_ID'].' has Title: '.$paginator['SUBJECT'].'<BR>';
}

?>




Model:

<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
class Model_Managers_Paginator{

public function simplepaginator(){
// require_once 'Zend/Paginator/Adapter/DbSelect.php';
$db = Zend_Db_Table::getDefaultAdapter();
$getdata = new Zend_Db_Select($db);
$getdata->from('ARC_DOCUMENT')
->where('DELETED=0');
}
}



?>
Hi,

I went through the TUTORIAL from Youtube and followed as exactly as it is. Following is the link for the video;

http://www.youtube.com/watch?v=f4fujot7Xlc


Even after understanding the logic in the video and following it exactly, Facing this problem;


Warning: include(Zend\Paginator\Adaptor\DbSelect.php) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\ZCFPRD\library\Zend\Loader.php on line 136

Warning: include() [function.include]: Failed opening 'Zend\Paginator\Adaptor\DbSelect.php' for inclusion (include_path='C:\wamp\www\ZCFPRD\library;.;C:\php5\pear') in C:\wamp\www\ZCFPRD\library\Zend\Loader.php on line 136

Fatal error: Class 'Zend_Paginator_Adaptor_DbSelect' not found in C:\wamp\www\ZCFPRD\application\controllers\DocumentsController.php on line 2144


I face this problem quite often but it slips off my brain how to cater it. Can someone please explain to me why I face this problem and what exactly I should do when I face it.

Please find the attached file to see my code.

Your earliest reply awaited

Regards,
YD




On Thu, Jul 29, 2010 at 4:18 PM, Brian Strickland <bstrick@gmail.com> wrote:
Oh and my view listed the numbers as so:

<div>
Pages: <?php echo $this->prev?> | <?php echo implode($this->pageLinks, $this->separator); ?> | <?php echo $this->next; ?>
</div>


On Thu, Jul 29, 2010 at 8:17 AM, Brian Strickland <bstrick@gmail.com> wrote:
I don't have time to go into detail, but here is my first attempt with paginator:

$page = $this->getRequest()->getParam('page');

// $data is what I got from the database.
    $pager = new Zend_Paginator(new Zend_Paginator_Adapter_Array($data));
   
        // set page number from request 
        $currentPage = $page;
        $pager->setCurrentPageNumber($page);
       
        // set number of items per page from request
        $itemsPerPage = 25;
        $pager->setItemCountPerPage($itemsPerPage);
        $pager->setPageRange(5);
       
        // get page data
        $pages = $pager->getPages();
       
        // create page links
        $this->view->pageLinks = array();
        $this->view->separator = ' | ';
       
        for ($x=1; $x<=$pages->pageCount; $x++) {
            if ($x == $pages->current) {
                $this->view->pageLinks[] = $x;     
            }
            else {
                $this->view->pageLinks[] = "<a href=\"/cpanel/author/search/$type/$value/$x\">".$x."</a>"; 
            } 
        }

Hope that helps some, sorry to be vague.

- strick
2010/7/29 Y D <dossany@gmail.com>

Hi all,

I am in desperate need to put pagination on the TABLE my clients view...I have seen there is a way Zend is dealing with it using ZEND_PAGINATOR but the explanation seemed a bit confusing to me.

Can anybody please help me out over here...Here is actually what I want For example;

1. The Number of Data Rows fetched are 450
2. The code only show 50 Records (ROWS)
3. For next the user has to click the NEXT PAGE link at the bottom or top.
4. The Next Page link is not active on Last page.
5. There is Previous page as well but ofcourse not active on the first page.

Please find the attached files to have an idea of how I am fetching the data using the query.

Your earliest respond awaited.

Thanks in advance





--
Regards,
YD

On Thu, Jul 29, 2010 at 4:18 PM, Brian Strickland <bstrick@gmail.com> wrote:
Oh and my view listed the numbers as so:

<div>
Pages: <?php echo $this->prev?> | <?php echo implode($this->pageLinks, $this->separator); ?> | <?php echo $this->next; ?>
</div>


On Thu, Jul 29, 2010 at 8:17 AM, Brian Strickland <bstrick@gmail.com> wrote:
I don't have time to go into detail, but here is my first attempt with paginator:

$page = $this->getRequest()->getParam('page');

// $data is what I got from the database.
    $pager = new Zend_Paginator(new Zend_Paginator_Adapter_Array($data));
   
        // set page number from request 
        $currentPage = $page;
        $pager->setCurrentPageNumber($page);
       
        // set number of items per page from request
        $itemsPerPage = 25;
        $pager->setItemCountPerPage($itemsPerPage);
        $pager->setPageRange(5);
       
        // get page data
        $pages = $pager->getPages();
       
        // create page links
        $this->view->pageLinks = array();
        $this->view->separator = ' | ';
       
        for ($x=1; $x<=$pages->pageCount; $x++) {
            if ($x == $pages->current) {
                $this->view->pageLinks[] = $x;     
            }
            else {
                $this->view->pageLinks[] = "<a href=\"/cpanel/author/search/$type/$value/$x\">".$x."</a>"; 
            } 
        }

Hope that helps some, sorry to be vague.

- strick
2010/7/29 Y D <dossany@gmail.com>

Hi all,

I am in desperate need to put pagination on the TABLE my clients view...I have seen there is a way Zend is dealing with it using ZEND_PAGINATOR but the explanation seemed a bit confusing to me.

Can anybody please help me out over here...Here is actually what I want For example;

1. The Number of Data Rows fetched are 450
2. The code only show 50 Records (ROWS)
3. For next the user has to click the NEXT PAGE link at the bottom or top.
4. The Next Page link is not active on Last page.
5. There is Previous page as well but ofcourse not active on the first page.

Please find the attached files to have an idea of how I am fetching the data using the query.

Your earliest respond awaited.

Thanks in advance
--
Regards,
YD





--
Regards,
YD

没有评论: