You are here: Re: mysql_insert_id() is it not problematic? « PHP Programming Language « IT news, forums, messages
Re: mysql_insert_id() is it not problematic?

Posted by Chris Hope on 01/26/06 23:06

Andy Hassall wrote:

> On 26 Jan 2006 12:55:40 -0800, opt_inf_env@yahoo.com wrote:
>
>>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. 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. And in this way the mysql_insert_id
>>initiated by the first user will return ID of insert-operation
>>initiated by the second user. If it is possible, how one can avoid
>>this problem?
>
> mysql_insert_id() is connection specific, and MySQL connections
> aren't shared
> between concurrent PHP requests, so this avoids the condition you
> describe.

What about if persistant connections are used? I'm a little unclear of
this myself. Does each PHP thread use a different persistant
connection, or can the share them? I would assume the former.

--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com

 

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

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