Re: Back from the dead with a racing question!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jason, 

>Do I need to be reading up on locking tables/rows? Or in my situation  
>as I've briefly described it do I not have to worry about it? Or is  
>there a third door with the magic bullet that will solve all my  
>problems? :)
>
>Any advice is greatly appreciated as always, RTFMing is good as well,  
>as long as M is defined :)
>
>

When using mysql along with PHPs mysql_insert_id() (http://de.php.net/manual/en/function.mysql-insert-id.php), the docs say:
<quote>
Note: 
   
    Because mysql_insert_id() acts on the last performed
    query, be sure to call mysql_insert_id() immediately 
    after the query that generates the value.
   
</quote>

So yes, from my point of view (which is in that case very paranoid), I'd say race conditions are possible to happen. One solution would be to save the user id along with the saved record, then fetch the last inserted record by this user and return the id for this record. A timestamp (microtime()) might also help.

On the other hand - yes, there is still the possbility of locking the table.

Regards

Thorsten


-- 
Thorsten Suckow-Homberg
Jakobstrasse 214-216
52064 Aachen
http://www.siteartwork.de

Tel.:  0151 -10927135
Email: ts@xxxxxxxxxxxxxx

You should follow me on Twitter: http://twitter.com/ThorstenSuckow

Sent with conjoon. Visit http://www.conjoon.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux