Hi,
I just started developing in Drupal and I am wondering how I can get the autoincrement field in MySQL.

For example, I have a table named FOOD with an autoincrement field called FOODID. After I insert a new FOOD record with db_query( "Insert into Food..." ), how can I get FOODID?

Thanks for you help!

Comments

chadj’s picture

LAST_INSERT_ID()

livido’s picture

Use function $id=mysql_insert_id(); after insert.

trungso.com - PHP programming service

jomesili’s picture

In my, I need to have an field that auto increments on my form after a field in the form has been updated, such as if case has been postpone, we need to know how many times the case has been posteponed,
what are your suggestions for getting this objective.