DB_common::nextId()

DB_common::nextId() -- Returns the next free id of a sequence

Synopsis

resource nextId (string $seq_name, boolean $onDemand = TRUE)

Description

See "Intro - Sequences"

Parameter

string $seq_name

name of the sequence

boolean $onDemand

when TRUE the sequence is automatic created, if it not exists.

Return value

integer - a free id number or a DB_Error object on failure

Throws

Table 26-1. Possible PEAR_Error values

Error codeError messageReasonSolution
DB_ERROR_NOT_CAPABLE DB backend not capable Function is not supported by the database backend Switch to another database system, if you really need this feature.
DB_ERROR_NOT_LOCKED not locked Locking of sequence table fails Database specific, check documentation of your database,
DB_ERROR_NOSUCHTABLE no such table Sequence table was not found Try to create a new sequence or if you are sure, a sequence was already create, check database integrity

Note

This function can not be called statically.

Warning

When using PEAR DB's sequence methods, we strongly advise using these methods for all procedures, including the creation of the sequences. Do not use PEAR DB's methods to access sequences that were created directly in the DBMS. See the warning on the "Intro - Sequences" page complete information.

Example

See

"Intro - Sequences", createSequence(), dropSequence()