ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:selectlimit

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
reference:selectlimit [2015/07/21 19:19] – [$rowsToReturn] mnewnhamreference:selectlimit [2015/08/01 18:11] mnewnham
Line 9: Line 9:
          string $sql,          string $sql,
          optional int $rowsToReturn=-1,          optional int $rowsToReturn=-1,
-         optional int $startOffset=1,+         optional int $startOffset=-1,
          optional string[] $bindvars=false          optional string[] $bindvars=false
          }          }
Line 22: Line 22:
  
 ===== $rowsToReturn ===== ===== $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. ''selectLimit()'' executed with -1 rows and -1 offset is the same as [[reference:execute|execute()]].+''$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 [[reference:execute|execute()]]
 + 
 +===== $startOffset ===== 
 +''$startOffset'' indicates the n<sup>th</sup> 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.
  
  
Line 31: Line 34:
  * DB2 Connection assumed  * DB2 Connection assumed
 */ */
-$ar $db->getAll("SELECT * FROM ACT");+$SQL = "SELECT * FROM act"
 +$result = $db->SelectLimit($SQL,2,3); 
 +while ($r = $result->FetchRow()) 
 +    print_r($r);
  
 /* /*
- $ar returns:+ Returns 2 rows starting at offset 3 (4th record starting at 0) 
 +  
 Array Array
 ( (
-    [0] => Array +    [0] => 40 
-        ( +    [1] => LEADPR 
-            [0] => 10 +    [2] => LEAD PROGRAM/DESIGN 
-            [1] => MANAGE +
-            [2] => MANAGE/ADVISE +Array 
-        +
- +    [0] => 50 
-    [1] => Array +    [1] => SPECS 
-        +    [2] => WRITE SPECS 
-            [0] => 20 +)
-            [1] => ECOST +
-            [2] => ESTIMATE COST +
-        ) +
- +
-    [2] => Array +
-        ( +
-            [0] => 30 +
-            [1] => DEFINE +
-            [2] => DEFINE SPECS+
  
-....... 
 */ */
                          
 </code> </code>
                    
v5/reference/connection/selectlimit.txt · Last modified: 2023/07/25 12:55 by dregad