On Mon, 19 Nov 2001 14:51, Justin French wrote:
> I'm inserting into a table (as I've done millions of times), and I have
> a column called "id", which is an auto incrementing, unique field.
> Since it's auto-increment field, I have no idea what it is at the time
> of insert, but I want to be able to report it to the screen.
> "Thankyour for your application, for future reference, your application
> # is "<the id number of the application i just inserted>."
> So, what I'd like to do is INSERT, then find out the id of the row I
> just inserted.
> I can't just look up the most recent id, because it's *possible* that
> someone else could have inserted after me.
> Also, at this stage the id field is the only unique field, so I can't
> try and match against annother field (of which I know the value I
> Any ideas?
> Justin French
mysql_insert_id is your friend, in this case. Even if someone inserts
another record, this function will return the auto ID for the last insert
performed using a given link identifier. So you feed it the link
identifier for _your_ insert, which of course you know, and Bob's yer
David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA
Vultures only fly with carrion luggage.
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]