Jump to content

[SOLVED] Fetch auto-incremented index ID while the row is being created


Errant_Shadow

Recommended Posts

I've been having a hard time finding this because I'm not sure how to ask it succinctly.

 

Basically, I'm entering new data rows into a database, but I then need to retrieve the auto-incremented primary key for use immediately after. I can't know what the key will be before I create the row (that I'm aware of), so I was wondering if there was anything I could do to retrieve that value without creating and running a separate query.

as a note: mysql_insert_id() MUST be called immediately after the insert query, even if the only other query run was not an insert. It will return 0 otherwise, rather than the insert id.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.