Re: Thread safe

From: Date: Wed, 29 May 2002 12:49:32 +0000
Subject: Re: Thread safe
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-99691@lists.php.net to get a copy of this message
Yeah but if you get a higher load of users that can get REALLY ugly....if it is strictly an update (editing of an already existing element) then locking that record should be fine but if it's an insert or delete you shouldn't lock the table. ed At 07:15 PM 5/28/2002 -0500, Miguel Cruz wrote:
If you use the database mechanism to lock the table during the transaction, then the second simultaneous invocation of your PHP program will wait (a tiny fraction of a second) until the first one is done. miguel On Wed, 29 May 2002, r wrote: since only my one program was accessing the table the database was safe, My question stands at what happens if 2 or more people access "enterdetails.php", click on the submit button to enter info into the same table at the same time? since I will be returning a valid ID no for each of them.......Its basically the old chopsticks puzzle and would like to know how does PHP handle it? -Ryan. ----- Original Message ----- From: "Miguel Cruz" <mnc@stoic.net> To: "r" <r@jumac.com> Sent: Tuesday, May 28, 2002 12:52 PM Subject: Re: [PHP] Thread safe
Well, that's not a thread safety issue if you're trying to lock a record in a database. If it was handled entirely within Java, then there was no guarantee of database referential integrity. Only the database can do that. miguel On Wed, 29 May 2002, r wrote:
Nope its not more like a database issue as this was clearly
addressed in
java and so the "synchronised" keyword was made and you have to
implement a
"synchronised block" of code to make it thread safe..... is this possible in PHP or does PHP itself take care to make all
scripts
thread safe? Cheers, -Ryan. ----- Original Message ----- From: "Miguel Cruz" <mnc@stoic.net> To: <php-general@lists.php.net> Sent: Tuesday, May 28, 2002 11:44 AM Subject: Re: [PHP] Thread safe
On Mon, 27 May 2002, r wrote:
In java servlets I used to use a "synchronised" block of code to
make
sure
it was thread safe...how do i do this in PHP? Heres what should be thread safe { $r=select max(cno)+1 from MyTable; (then i insert into the table the new cno plus my name) insert into mytable ($r,'myname'); } How to do this and make sure its thread safe?
More of a database issue. "select ... for update" is a good starting
point
as you search the manual of your particular database platform. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#99691) next »