Getting the value of an auto-increment
| From: | timbo at komrades dot dyndns dot org | Date: | Thu, 10 Apr 2003 23:59:04 +0000 |
| Subject: | Getting the value of an auto-increment | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-26996@lists.php.net to get a copy of this message | ||
Hello,
I'm using an auto-increment field in a table as the primary key. What I
want to know is when I use an INSERT query to add a row to the table is
there a way I can get the value of the auto-increment field of the row
that was just inserted?
What I'm currently doing is messy but works:
I get the current time and session id and write them to one of the fields
in the row and INSERT that. I then do a query and find the row (thus
getting the value of the auto-increment field) and then write the real
data.
I'm just hoping there's an easier way.
Thanks in advance,
Tim Coombes
Komrades Ink.