- 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:genid

# genId

      int genId(
         optional string $sequenceName='adodbseq',
         optional int $startPoint=1
         )

## Description

The function `genId()` is a useful, portable way of generation sequence numbers. This is not the same as having an auto-increment row on a table. If the requested sequence name does not exist, it automatically calls createSequence() to create it.It uses the best method available for a database, at best using the inbuilt sequencing functionality, and at the lowest end, maintaining a table with an integer field that is incremented using SQL syntax.

The optional parameters control the sequence name and the start number for the sequence. The return value is the sequence number.

## Usage

    $number = $db->genId('newsequence',100);
    /*
     * Creates a new sequence number automatically, starting at 100
     *
     * number returns 100
     */
    $number = $db->genId('newsequence');
    /*
     * Number returns 101
     */

v5/reference/connection/genid.txt · Last modified: 2016/01/16 15:55 by mnewnham

### Page Tools

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