adobe photoshop 60 download

Adobe Premiere Pro CS5 discount free adobe dream weaver 8 download free download adobe distiller cheapest adobe photoshop free download full version where does adobe save download video files

adobe bridge download

Adobe Creative Suite 4 for Mac buy cheap download adobe photoshop elements 5 adobe download free premiere pro buy cheap adobe acrobat 8 download purchase adobe photoshop cs3 extended full download

free adobe download manager

buy cheap Adobe cs5 Design Premium for Mac adobe acrobat reader 6 0 1 free download adobe flashplayer download softpedia discount download adobe after effects download adobe after effects

free download adobe illustrator 9

cheapest Adobe cs5 for Mac adobe cs2 download free crack key generator how to download adobe flash movies cheapest adobe acrobat reader free download adobe 8 free download

free adobe download

Autodesk AutoCAD cheapest adobe download free premiere adobe distiller free download discount download adobe flashplayer free adobe download manager download

adobe audition 1 5 download

cheap AutoCAD Architecture adobe acrobat 8 free download adobe creative suite 2 download cheapest download adobe premiere pro cs3 download adobe reader cd

adobe encore menu download

cheapest Adobe Captivate CS5.5 download adobe ebook reader adobe photoshop elements 3 for mac download cheap download adobe photoshop 7 download adobe flash player

download adobe reader latest version

discount Creative Suite 5.5 download adobe photoshop cs2 adobe photoshop 8 free download full version discount download free adobe standard adobe flas player 9 download

download adobe photoshop mac free

Autodesk AutoCAD discount free adobe 8 download free download of adobe pagemaker buy cheap adobe dream weaver 8 download download adobe scanner

adobe reader download for mac

discount AutoCAD 2010 free adobe download free download of adobe reader buy cheap free download adobe photodeluxe home edition adobe flash player 8 download

adobe lightroom download

AutoCAD LT 2012 buy cheap adobe golive cs2 download freeware adobe acrobat download cheap adobe flash activex download download adobe flashplayer

adobe flash 9 download

adobe acrobat x buy cheap adobe free download software download adobe photoshop cs2 cheap download adobe audition 3 free adobe premiere download

adobe flash offline download

adobe creative suite 5 discount download adobe acrobat reader 8 adobe 9 download discount free adobe photoshop elements 6 download download adobe reader pdf free

search adobe reader 7 0 download

cheap adobe cs5 adobe acrobat writer free download adobe fine reader free download cheap adobe player download center adobe professional download

download adobe flashplayer free

Adobe cs5 Design Premium cheapest where free download adobe acrobat free download of adobe reader buy cheap adobe flash 7 download download adobe reader8

free adobe acrobat writer download

Adobe eLearning Suite cheap download adobe active x download adobe acrobat 7 updates discount download adobe flash 9 for h264 free adobe pdf maker download

adobe photo plus 6 download

discount Adobe eLearning Suite 2 download adobe photoshop cs2 adobe illustrator full crack download cheapest adobe photoshop download site adobe acrobat raeder v7 download

adobe flash player download for windows vista

discount Adobe Flash Catalyst CS5 adobe photo editor download adobe reader 6 free download discount download adobe flashplayer free free download adobe illustrator 9

adobe shockwave player download

discount Adobe Indesign CS5 free adobe dream weaver 8 download adobe photo free download cheapest adobe flash player downloader free download hunter grabber free adobe profesional 8 download

adobe type manager download free

discount Adobe Photoshop CS5 download adobe acrobat reader free old adobe software download discount download adobe flash player stand alone adobe acrobat update download

Pagination | Using Pager with Doctrine | sfDoctrinePager | Symfony | PHP | MVC Framework

As symfony is updated frequently i decided to update my skills too . I have been into many symfony project but the ORM used was Propel but the latest version supports Doctrine , so planned to do a project using doctrine .

As i like yml than xml , wrote schema using in yml and succeeded in generating the model , sql and inserted successfully . But implementing pagination using pager was not simple as i thought . After some research implemented it successfully and i am sharing you the code with you .

Code in action page


public function executeIndex(sfWebRequest $request)
 {
 $this->pager = new sfDoctrinePager('TableName', '5');
 $this->pager->setQuery(Doctrine::getTable('TableName')->createQuery('a'));
 $this->pager->setPage($request->getParameter('page', 1));
 $this->pager->init();
 }

The above code fetches 5 results from the table .

Code within template page :


<?php foreach ($pager->getResults() as $metro_bussiness_list): ?>
<tr>
 <td><?php echo $metro_bussiness_list->getMetroCategoryId() ?></td>
 <td><?php echo $metro_bussiness_list->getTitle() ?></td>
 <td><?php echo $metro_bussiness_list->getImage() ?></td>
</tr>
<?php endforeach; ?>

<div style="width:20px;float:left;margin-top:3px;margin-right:10px">
<?php echo link_to('first', 'module/index?page='.$pager->getFirstPage()) ?>
</div>

<div>
<?php if ($pager->haveToPaginate()): ?>
<?php $links = $pager->getLinks(); foreach ($links as $page): ?>
<div style="padding:5px 5px 5px 5px;border:#000000 thin solid;float:left;width:10px;margin-left:3px;font-size:10px" >
<?php echo ($page == $pager->getPage()) ? $page : link_to($page, 'bussiness/index?page='.$page) ?>
</div>
<?php endforeach ?>
<?php endif ?>
</div>

<div style="width:20px;float:left;margin-left:10px;margin-top:3px;">
<?php echo link_to('last', 'module/index?page='.$pager->getLastPage()) ?>
</div>

It’s done . Hope it helped you to implement it .

Source of the article .

About the Author: a holistic web developer , movie buff and technical blogger from queen of arabian sea.

RSSComments (14)

Leave a Reply | Trackback URL

  1. mel_06 says:

    nice code! thanks!
    i’m just new to symfony and it really helped me.

    by the way, how can i add an descending order on this:
    $this->pager->setQuery(Doctrine::getTable(‘TableName’)->createQuery(‘a’));

    thanks!

  2. anoopsachari says:

    Try this to sort in desc order and let me knw . :)

    $this->pager->setQuery(Doctrine::getTable(‘TableName’)->createQuery(‘a’)->orderBy(‘a.id DESC’));

  3. mel_06 says:

    wow! it worked man!

    you’re really awesome!

    one last thing, favor that is! i’m listing it by category. i’m doing a list of laptops by brands(category) and models( DESC – latest down to the oldest).

    thanks man!

  4. mel_06 says:

    i forgot to say that the category and models are on both different tables.

  5. anoopsachari says:

    @chris Thankyou for the info . I was new to doctrine when i wrote this article . So tried to implement pagination using pager .

  6. sami says:

    Hey everybody;
    can you see this code pager PLEAAAASE it don’t work :( and i don’t now where is the probleme

    public function executeList(sfWebRequest $request)
    {
    $Shops = Doctrine::getTable(‘Shop’)
    ->getAllShops();

    $numPage = $request->getParameter(‘page’, 1);

    $this->pager = new sfDoctrinePager(‘Shop’, 4);
    $this->pager->setQuery($Shops);
    $this->pager->setPage($numPage);
    $this->pager->init();

    }

    _paginate.php

    getRouting()->getCurrentInternalUri(false) ?>

    getPreviousPage()) ?>

    getLinks() as $page): ?>
    getPage() == $page): ?>

    getNextPage()) ?>

    getLastPage()) ?>

    listSuccess.php

    getResults() as $shop): ?>

    getPresentation(); ?>

    haveToPaginate()): ?>

    $pager)) ?>

    getRouting()->getCurrentInternalUri(false) ?>

    public function getAllShops() dans ShopTable.class.php
    {
    $q = $this->createQuery(‘p’)
    ->execute();
    return $q;
    }
    thank’s soo muuuuuch

  7. aagii says:

    very nice. thanks

  8. [...] working with Doctrine for the first time. This is a good explanation of handling pagination. [...]

  9. Maikel says:

    Hey dudes I just have a quick question;

    Can I use this pager more than once on a page? I mean, you can add another query and make another $nav variable with another name, but you can’t really give another get variable as it will always be ‘page’..

  10. Nicolas Ard. says:

    Good post!,
    Very simple explained, and useful.

  11. Bigmizar says:

    Thank you! Very usefull. :)

  12. Anil says:

    HI, i am new to symfony and php as well, is there any sample using facebook connect plugin

    Thanks
    Anil

  13. Basma says:

    It’s works!!! Thank you thank you thank you thank you, you’re a life saver! i looked all over the place for this!!! Good job!

Leave a Reply

Get Adobe Flash playerPlugin by wpburn.com wordpress themes