Search code examples
phpgeneratorfirebird

Firebird PHP generator for auto increment


I have a key ID which would be an auto-incremented unique ID for a Firebird database, and I have a generator made in firebird, already working perfectly, and I want to write the ID in the db for new records. So basically I want to get the correct value with this incrementer generator, but I don't know how to call. PRODUCT_SORSZAM is the generator.

$q = ibase_query("SELECT * FROM PRODUCT_SORSZAM");
echo $q;

Solution

  • You can use following to get next generator value:

    SELECT GEN_ID(PRODUCT_SORSZAM,1) FROM RDB$DATABASE; Or 
    SELECT NEXT VALUE FOR PRODUCT_SORSZAM FROM RDB$DATABASE;
    

    I assume that PRODUCT_SORSZAM is name of generator, not the name of table.