Thanks Mark...

You popped me out of great confusion/problem.

Binay
----- Original Message -----
From: "Mark Maunder" <[EMAIL PROTECTED]>
To: "Binay" <[EMAIL PROTECTED]>
Cc: "mysql users" <[EMAIL PROTECTED]>
Sent: Thursday, February 19, 2004 3:03 PM
Subject: Re: Last inserted id


> 'connection ID' below should be 'last insert id'. Sorry, it's 2am here
> and I'm fresh out of coffee. BTW the information you want is here:
> http://www.mysql.com/doc/en/Information_functions.html#IDX1409
>
> "The last ID that was generated is maintained in the server on a
> per-connection basis. This means the value the function returns to a
> given client is the most recent AUTO_INCREMENT value generated by that
> client. The value cannot be affected by other clients, even if they
> generate AUTO_INCREMENT values of their own. This behavior ensures that
> you can retrieve your own ID without concern for the activity of other
> clients, and without the need for locks or transactions."
>
>
> On Thu, 2004-02-19 at 09:26, Mark Maunder wrote:
> > The two simultaneous insert statements will be have separate connections
> > to the database and last_insert_id() is connection specific. So if
> > you're running apache, and you're worried about two different apache
> > child processes getting the same connection ID, don't. Because those two
> > children will have separate connections to the DB.
> >
> > If you're forking or threading and using the same connection, it becomes
> > a bit more complex.
> >
> > Mark.
> >
> > On Thu, 2004-02-19 at 09:17, Binay wrote:
> > > Hi
> > >
> > > I have a php script which insert a row in one of my table. Now i want
the auto_generated id produced by this insert query. I know i can use
mysql_insert_id function to fetch that auto_generated id. But my question is
say two or more person visiting the same page/script causes a insert
operation in the table at the same time. so there are chances of getting
wrong auto_generated ids for different visitors. why am i saying this can be
clear from below example.
> > >
> > > Say one insert operation is in the progress and by the time control
switches/call to mysql_insert_id function another insert operation starts ..
so ultimately mysql_insert_id will fetch 2nd insert operation id which
should not be the case. How to resolve this case??
> > >
> > > Thanks
> > >
> > > Binay
> --
> Mark Maunder <[EMAIL PROTECTED]>
> ZipTree.com



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

Reply via email to