Andre Matos wrote:
The idea is to have a audit trail to record the changes made. So, I want to
insert a new record in the "staff" table and right after this, insert a
record in the "changes" table.

SET AUTOCOMMIT=0;
START TRANSACTION;
INSERT INTO staff (`Name`) VALUES ('ABC');
INSERT INTO changes (`Key`, `Table`, `Value`) VALUES (LAST_INSERT_ID(),
'staff', 'ABC');
COMMIT;
SET AUTOCOMMIT=1;

This works fine in my test environment, however what about many users doing
at the same time. Does the LAST_INSERT_ID() get the correct ID for each
user?
LAST_INSERT_ID() is connection-specific so the ID will be the one that was assigned during this particular PHP page's connection to the database.


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to