You are here: Re: is mysql_insert_id safe « PHP Programming Language « IT news, forums, messages
Re: is mysql_insert_id safe

Posted by Gordon Burditt on 06/13/06 17:18

>> With regard to mysql's mysql_insert_id function is it possible that the
>> query can return the insert id from another insert performed by a
>> another user of the database which occured after the initial insert by
>> the first user but b4 the insert_id part can be queried.
>>
>
>You won't have any problems if you're running it immediately after the
>query.

In the database world, there is no "immediately after". It's always
possible for someone else to get in a query between any two of
yours. It's up to locking (implicit or explicit) or transactions
to prevent bad effects on the data from this by delaying execution
of one until another finishes.

mysql_insert_id() returns the last insert id ON THIS CONNECTION.
So, as long as you keep the connection open (which probably won't
be beyond the processing of the PHP page: with persistent connections,
you are NOT guaranteed to get the same connection next time), you
can wait as long as you want to call mysql_insert_id().

Gordon L. Burditt

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация