Concurent requests

From: Date: Fri, 09 Mar 2001 12:49:40 +0000
Subject: Concurent requests
Groups: php.general 
Request: Send a blank email to php-general+get-43137@lists.php.net to get a copy of this message
Please, any idea how to manage concurent requests, for example like in a shopping cart? Scenario: 1. I have a counter A (a field in a database row), set to 1, so A=1 2. A client wants 1 unit from A , it checks and it's OK, there is available. 3. Another client wants 1 unit from A, it checks, and it's OK, because first client did not subtracted yet 1 unit from A 4. The first client decreases A, so A=0 5. The scond client decreases A, so A=?... some garbage... Any idea how to fix this transaction problem? If A is locked by the first client in order to fix this problem, there is another question (the really one!): If the program terminates unexpectedly, what about A? It remains locked forever, and the second client cannot use it anymore ? thanx! any idea really apreciated! Daniel BI

« previous php.general (#43137) next »