- skip to content

# Database Abstraction Layer

### User Tools

- Login

### Site Tools

- Recent changes
- Media Manager
- Sitemap

### Sidebar

##### Resources

- Reference Manual
- User Guide
- The Data Dictionary
- ADOdb-xmlschema
- ADOdb Active Record
- Performance Monitoring
- Date/Time Library
- Session Management Library
- Unsupported Addons
- Coding Standards

##### Supported Databases

- Access
- ADO
- CSV
- Firebird
- Frontbase
- IBM DB2
- Informix
- Interbase
- LDAP
- Microsoft SQL Server
- MySQL
- Netezza
- ODBC
- ODBTP
- Oracle
- PDO
- Postgresql
- SAP ADS
- SAP ASE
- SAP Maxdb
- SAP Sqlanywhere
- Sqlite
- Sybase
- Plain Text
- Visual Foxpro

##### Other

- Feature Comparison Matrix
- Connection Matrix
- Include File Guide

v5:reference:connection:selectlimit

# selectLimit

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=false
           }

## Description

The function executes a statement, and returns a handle to a recordset or false if the statement execution fails.

The presentation of the returned data can be modified by the variables $ADODB_FETCH_MODE and $ADODB_ASSOC_CASE and the function setFetchMode().

For a detailed description of the `$sql` and `$bindvars` parameters passed, see 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 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
    )

    */

v5/reference/connection/selectlimit.txt · Last modified: 2016/01/19 12:18 by 66.249.64.103

### Page Tools

- Show pagesource
- Old revisions
- Backlinks
- Rename Page
- Back to top