Charles Whitaker wrote:
Using persistant connections simply means that you will be given a
connection from a pool of open connections rather than creating a new
one each time. There is no guarantee you'll get the same connection
from request to request.
Right. I had assumed that I would get a connection previously initiated
by me, and that there would therefore be only one, so I would always get
the same connection. So much for assumptions.
I would suggest you add another field to the table you are trying to
lock. Put an ID in there that you can pass from request to request.
Use the locking feature to lock the table, read that value for a
record, if it's not set to something write your ID to it then unlock
it. If it does already contain an ID you treat it as locked. you just
need to make sure you unlock the row when you're done (probably by
setting that value to NULL.
If you're already using sessions I would strongly recommend using the
session ID as the lock ID. If not you can easily generate one but
you'll need to pass it manually from request to request.
I did as you suggest, and it seems to work fine. I surrounded the lock
code with get_lock() and release_lock(), to make it quasi-atomic.
Thanks for the suggestion, and thanks to Charles Morris as well for his
response.
No problem, but please include the list when replying in future.
-Stut
--
http://stut.net/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php