Location: PHPKode > scripts > RC4PHP class > rc4php-class/sql_paging.txt
RC4PHP (Raul's Classes for PHP) paging
===========================================================

MSSQL paging
------------

-------------------------------------------------------------------------------------
NOTE: Be sure to give to the SQL user, rights to create & execute stored proceedures!
-------------------------------------------------------------------------------------

First of all, in order to get pagination support implemented, This class will
calculate the total number of rows returned by the SQL query.  This is done by 
the _getTOTALRows() method. 

Instead of running the query and obtaining the number of rows from 
mssql_num_rows(), I use the following method: 

"SELECT COUNT(*) 
FROM (yourQuery) AS ___qry___". 

After this I'll use the _getSQLQueryString() method which modifies the SQL 
querry in the following way:
	1. Calculates the md5 hash of the SQL command.
	2. Checks if a stored procedure with name "RC4PHPpagination_" followed by
	   the md5 hash calculated on step 1 exists. If not, then it is created based
	   on your query. 
	3. Then, using the sp_cursoropen, sp_cursorfetch and sp_cursorclose system 
	   procedures, only the required rows are fetched and sent to the client 
           from the stored procedure call.

MySQL, PostgreSQL & SQLite paging
---------------------------------
The paging is made by using LIMIT.
Return current item: RC4PHP class