download adobe pagemaker 7

buy cheap Adobe Photoshop CS5 adobe photo plus 6 download free download adobe illustrator 9 discount crack adobe photoshop cs3 download adobe download free pagemaker

adobe illustrator cs2 trial download

Adobe Acrobat X Suite cheap download hustler in adobe format adobe acrobat download for mac cheap acrobat adobe download reader standard download latest adobe acrobat reader

download adobe photo shop album

cheap Dreamweaver CS5 adobe acrobat reader 4 download adobe illustrater download cheapest adobe flashpayer download download free adobe acrobat 5

free adobe photoshop software download

Adobe Contribute CS5 for Mac cheapest adobe illustrator full crack download free adobe pdf maker download cheap macintosh download adobe acrobat reader adobe shockwave download

download adobe version 7

Adobe Photoshop CS5 MAC cheap free download for adobe photo start album adobe shockwave download cheapest adobe illustrator trial download adobe 8 updates download

adobe pagemaker free full download

discount AutoCAD 2011 adobe illustrator svg filter download download adobe acrobat reader system 9 cheapest adobe photoshop download adobe illustrator download free

search adobe reader 7 0 download

cheapest AutoCAD Architecture dreamweaver 8 download adobe adobe mp9 free download buy cheap adobe reader german download adobe indesign 2 0 download

adobe photoshop 5 download

Adobe Dreamweaver CS5.5 buy cheap adobe flashplayer 9 download adobe photoshop cs2 patch download buy cheap download adobe photoshop cs2 download adobe writer utorrent

download adobe audition 3

Adobe Indesign CS5.5 buy cheap adobe page maker full download adobe photo shop download free cheap download adobe photoshop 60 free download adobe rea

adobe acrobat 8 free download

cheap Adobe Creative Suite 5.5 adobe professional free download adobe cs3 free download cheap adobe version 6 download free download adobe reader for linux

adobe reader 8 free download

AutoCAD 2010 discount adobe dream weaver 8 download adobe keygen ssg download cheapest adobe player 8 download download cracker adobe acrobat

adobe acobat free download

discount AutoCAD 2011 adobe acrobat reader 4 download adobe download free photo shop buy cheap download adobe readere adobe illustrator to download

download adobe photoshop 7 trial

cheapest AutoCAD LT adobe download photo shop trial adobe macromedia flash download cheap cheap oem adobe in design download sony mini dv download to adobe

adobe flas player 9 download

adobe acrobat x discount download adobe program change documents adobe premiere pro cs3 crack download cheap how to download a adobe flash player video adobe download photo shared shop

download adobe photodeluxe

discount adobe acrobat x suite adobe encore dvd download australia adobe lightroom trial download buy cheap adobe photoshop 70 download microsoft adobe reader download

adobe premire download

cheap adobe creative suite 5 adobe acrobat download adobe photo shop trial download buy cheap download adobe creative suite 2 premium free download for adobe acrobat

download adobe imageready

adobe creative suite for mac discount adobe flash player plug in download download adobe shockwave 5 discount adobe photoshop free download adobe photo free download

download adobe photoshop cs3 free

Adobe cs5 Production Premium cheapest free download adobe acrobat reader professional 6 cracked free adobe 6 download buy cheap download free adobe photoshop elements adobe reader download mac osx

download gratis adobe after efects cs3 profesional

discount Adobe Dreamweaver CS5 download adobe reader latest version how to download pages with adobe flash discount adobe flash download mirror adobe professional free 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