Re: pear::db limitQuery and MS SQL Server

From: Date: Tue, 06 May 2003 22:05:20 +0000
Subject: Re: pear::db limitQuery and MS SQL Server
References: 1 2 3 4  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-5248@lists.php.net to get a copy of this message
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

« previous php.pear.general (#5248) next »