View previous topic :: View next topic |
Author |
Message |
Toasty -
Joined: 21 Feb 2008 Posts: 298 Location: Chicago, IL
|
Posted: Mon Mar 30, 2009 4:30 pm Post subject: MySQL Incremented Key |
|
|
Hello.
I can't seem to figure out a way to do this, while looking around online:
Say if I just inserted a row into a database with PHP:
Code: | INSERT INTO database.table (`unique`, `othervar1`, `othervar2`) VALUES (NULL, 'var1', 'var2'); |
How would I find out right after the transaction occured what value MySQL put into the "unique" variable? Any help would be appreciated!
Thanks,
Toasty _________________ Audit the secure configuration of your server headers! |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
pkSML -
Joined: 29 May 2006 Posts: 952 Location: Michigan, USA
|
Posted: Mon Mar 30, 2009 5:06 pm Post subject: |
|
|
Is 'unique' set to auto-increment in your table setup? If so, then after the insert command is finished, you can use mysql_insert_id. _________________ Stephen
Need a LitlURL?
http://CodeBin.yi.org |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Toasty -
Joined: 21 Feb 2008 Posts: 298 Location: Chicago, IL
|
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Toasty -
Joined: 21 Feb 2008 Posts: 298 Location: Chicago, IL
|
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
|