irm-1.6-b3/MDB/fbsql.php
/**
     * returns the next free id of a sequence
     *
     * @param string  $seq_name name of the sequence
     * @param boolean $ondemand when true the seqence is
     *                          automatic created, if it
     *                          not exists
     *
     * @return mixed MDB_Error or id
     * @access public
     */
returns the next free id of a sequence
@param string  $seq_name name of the sequence
@param boolean $ondemand when true the seqence is
automatic created, if it
not exists

@return mixed MDB_Error or id
@access public
returns the next free id of a sequence @param string $seq_name name of the sequence @param boolean $ondemand when true the seqence is automatic created if it not exists @return mixed MDB_Error or id @access public
function nextId($seq_name, $ondemand = TRUE)
    {
        $sequence_name = $this->getSequenceName($seq_name);
        $this->expectError(MDB_ERROR_NOSUCHTABLE);
        $result = $this->query("INSERT INTO $sequence_name VALUES (NULL)");
        $this->popExpect();
        if ($ondemand && MDB::isError($result) &&
            $result->getCode() == MDB_ERROR_NOSUCHTABLE)
        {
            $result = $this->createSequence($seq_name, 2);
            if (MDB::isError($result)) {
                return($this->raiseError(MDB_ERROR, NULL, NULL,
                    'Next ID: on demand sequence could not be created'));
            } else {
                return(1);
            }
        }
        $value = intval(@fbsql_insert_id());
        $res = $this->query("DELETE FROM $sequence_name WHERE ".$this->options['sequence_col_name']." < $value");
        if (MDB::isError($res)) {
            $this->warnings[] = 'Next ID: could not delete previous sequence table values';
        }
        return($value);
    }
function nextId ( $ seq_name , $ ondemand = TRUE ) { $ sequence_name = $ this -> getSequenceName ( $ seq_name ) ; $ this -> expectError ( MDB_ERROR_NOSUCHTABLE ) ; $ result = $ this -> query ( " INSERT INTO  $ sequence_name  VALUES (NULL) " ) ; $ this -> popExpect ( ) ; if ( $ ondemand && MDB :: isError ( $ result ) && $ result -> getCode ( ) == MDB_ERROR_NOSUCHTABLE ) { $ result = $ this -> createSequence ( $ seq_name , 2 ) ; if ( MDB :: isError ( $ result ) ) { return ( $ this -> raiseError ( MDB_ERROR , NULL , NULL , 'Next ID: on demand sequence could not be created' ) ) ; } else { return ( 1 ) ; } } $ value = intval ( @ fbsql_insert_id ( ) ) ; $ res = $ this -> query ( " DELETE FROM  $ sequence_name  WHERE  " . $ this -> options [ 'sequence_col_name' ] . "  <  $ value " ) ; if ( MDB :: isError ( $ res ) ) { $ this -> warnings [ ] = 'Next ID: could not delete previous sequence table values' ; } return ( $ value ) ; }
returns the next free id of a sequence
 @param string  $seq_name name of the sequence
 @param boolean $ondemand when true the seqence is
                          automatic created, if it
                          not exists
returns the next free id of a sequence @param string $seq_name name of the sequence @param boolean $ondemand when true the seqence is automatic created if it not exists
// Since we are create the sequence on demand // we know the first id = 1 so initialize the // sequence at 2 // First ID of a newly created sequence is 1