Re: pear::db limitQuery and MS SQL Server
| From: | Geoff | Date: | Wed, 07 May 2003 14:50:12 +0000 |
| Subject: | Re: pear::db limitQuery and MS SQL Server | ||
| References: | 1 2 3 4 5 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-5255@lists.php.net to get a copy of this message | ||
Thanks Markus this does the trick I just need to output the page number
links and its a wrap.
On Tue, 2003-05-06 at 18:05, Markus Wolff wrote:
> Geoff wrote:
>
> > OK here is the code. I'm sure it's something I'm doing wrong. I'm
> > using
> > a custom class to convert the result set into xml so it's a bit messy.
>
> Whoah, just the code regarding the pager class would have been enough
> I guess ;-)
>
> Okay, try this... make a query using $db->query() just as usual, no
> limitQuery, no special SQL commands. Pass the result object, the
> number of the first row you want to begin with and the number of rows
> per page to the constructor of a new DB_Pager object:
>
> $pager = new DB_Pager($resultObject,$_GET["startRow"],$rowsPerPage);
> $pageData = $pager->build();
>
> In $pageData you´ll now have an array with all the data you need to
> display some paging information on your page. Use print_r() or the
> DB_Pager docs for details. You can fetch the rows of the current page
> like this:
>
> $row = $pager->fetchRow(DB_FETCHMODE_ORDERED); // or _ASSOC or...
>
> Build a link to the next page like this:
> $url = $_SERVER["PHP_SELF"]."?startRow=".$pageData["next"];
>
> And so on... I think from here everything explains itself more or less...
>
> Regards,
> Markus
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>