On Sat, 2008-10-18 at 12:54 +0200, Alain Roger wrote:
> Hi,
> 
> i would like to know what is the best approach for paging ?
> usually i use PEAR and page thanks their table library, but to avoid high
> transfer of data from DB to PHP page it is better to do the paging at
> database level.
> I would like to know what is your point of view on this topic and what do
> you use to do ?
> 
> thx.
> 
I've not used a library to achieve paging but doing it at the database
level is a must really, as you don't want to retrieve large data sets,
only to work on a small sub-section of them. As I've no experience of
using libraries for this, I've always coded the queries myself. LIMIT in
MySQL comes in real handy, but if you're using an older version of
MSSQL, then you will have to use nested selects like this:

SELECT * FROM
(
    SELECT TOP 10 * FROM
    (
        SELECT TOP 20 * FROM table1 ORDER BY column1
    )
    ORDER BY column1 DESC
)
ORDER BY column1

Obviously the syntax is not entirely right, but it should help you get
the general idea for a query that returns results 10-20.


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to