|
Posted by Gordon Burditt on 01/26/06 23:02
>I would like to insert a data (row) into database (MySQL) and than to
>generate file whose name contains the ID of the inserted row (ID is
>declared as AUTO_INCREMENT). I wanted to extract ID by
>mysql_insert_id() function.
This works, and it works *PER CONNECTION*.
It returns the last ID inserted *on this connection*.
>However, the problem is that my web site
>can visit many users and many of them can initiate the describe
>procedure. It can happen that between the first user inserts something
>into database and executes mysql_insert_id, the second user also insert
>something into database.
Fine.
>And in this way the mysql_insert_id initiated
>by the first user will return ID of insert-operation initiated by the
>second user.
No, that won't happen. mysql_insert_id() works *PER CONNECTION*.
>If it is possible, how one can avoid this problem?
It already is avoided.
Gordon L. Burditt
Navigation:
[Reply to this message]
|