[thelist] SELECTing and auto_increment field

Andrew Forsberg andrew at thepander.co.nz
Thu Sep 13 17:24:11 CDT 2001


PHP's mysql_insert_id() returns the last auto_incremented value, or 
the auto_incremented value of a given result resource, which means I 
can let mysql set the timestamp automagically too.

Another case of rtfm.


>If the database supports single threading, then you can put it into single
>thread mode, do the insert, do a select max on the id, and carry one.
>Otherwise, some of the possible approached may depend on your middleware if
>you .  What are you using?  PHP?  CF?  ASP?  etc
>A common technique is to put the middleware in single thread mode, generate
>a UID based of the time, return from single threaded mode, and use the UID
>in the insert and subsequent select.  Then you have the id off the record
>and you can discard the UID.
>----- Original Message -----
>From: "Andrew Forsberg" <andrew at thepander.co.nz>
>Subject: [thelist] SELECTing and auto_increment field
>: Hi all
>: There's got to be a really simple solution that I'm overlooking here.
>: I'd like to know what the auto_incremented field of an insert into a
>: mysql table is, but preferably without having to run a hokey select
>: after the insert. At the moment I'm doing this:

Andrew Forsberg
the pander - http://thepander.co.nz/
uberNET - http://uber.net.nz/

More information about the thelist mailing list