====== selectLimit ======
~~NOTOC~~
The order of the ''$rowsToReturn'' and ''$startOffset'' variables may not match the order specified in the underlying PHP function
== syntax ==
mixed selectLimit(
string $sql,
optional int $rowsToReturn=-1,
optional int $startOffset=-1,
optional string[] $bindvars=null,
optional string[] $cacheParameters=null
}
===== Description =====
The function executes a statement, and returns a handle to a recordset or false if the statement execution fails. The statement also supports use of the [[v6:memcache|Memcache]] service
The presentation of the returned data can be modified by:
* [[v6:reference:adodb_fetch_mode|fetchMode]] class variable,
* [[v6:reference:adodb_assoc_case|assocCase]] class variable,
* [[v6:reference:connection:setfetchmode|setFetchMode()]] function.
For a detailed description of the ''$sql'' and ''$bindvars'' parameters passed, see [[v6:reference:connection:execute|execute()]].
===== $rowsToReturn =====
''$rowsToReturn'' indicates the maximum number of rows for the request to return. If End-Of-File is reached, the number returned my be less. If the value is -1, then all rows starting at the requested offset are returned. ''selectLimit()'' executed with -1 rows and -1 offset is the same as [[v6:reference:connection:execute|execute()]].
===== $startOffset =====
''$startOffset'' indicates the nth row at which to start the request. Row numbers start at 0. If the row number is beyond End-Of-File then an empty recordset will be returned.
==== Usage ====
/*
* DB2 Connection assumed
*/
$SQL = "SELECT * FROM act";
$result = $db->selectLimit($SQL,2,3);
while ($r = $result->fetchRow())
print_r($r);
/*
* Returns 2 rows starting at offset 3 (4th record starting at 0)
Array
(
[0] => 40
[1] => LEADPR
[2] => LEAD PROGRAM/DESIGN
)
Array
(
[0] => 50
[1] => SPECS
[2] => WRITE SPECS
)
*/
=== Using the Memcache service ===
$SQL = "SELECT * FROM act";
$result = $db->selectLimit($SQL,2,3,null,array('cache'=>true));