elrial
Posts: 12
|
| Posted: 10/24/2007, 5:47 AM |
|
Hi,
I'm sure there is a way to do it in ASP but is there a way to stop all insert statements while retrieving the info of the last record in PHP?
I need to select the last email address inserted but what if someone adds their details while I'm selecting and I end up selecting the wrong record?
I know this is a first grade question, but I simply didn't know where else to ask, if anyone can point me in the right direction I'd be so grateful.
|
 |
 |
wkempees
Posts: 1679
|
| Posted: 10/24/2007, 5:54 AM |
|
Search the forum for last_insert_ID to get the code for this in MySQL.
You do not have to stop the database, it works like this:
After SQL INSERT has done it's work, you SELECT LAST_INSERT_ID on the table in question.
It will alwasy return the correct ID, as long as you do it in the same dbconnect.
So do not open a new connection, just do the select.
If your insert is a multi row insert, the last ID is returned, which is another problem as you have to query the number of inserted rows also.
But if you stick to the above, it should work ok.
Hint: After INSERT
Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
|