Charles Whitaker wrote:
Since I'm requesting persistent connections, why don't I get the same connection each time? Or, to ask it another way: I notice that the number of threads slowly increases as I continue to access records -- why would this happen if I'm using persistent connections? I assumed that the first time I did 'new PDO' I'd create a connection, and each time after that I'd get the same connection. At least that's how I read the documentation.

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.

Can anyone point me in the right direction? Thanks.

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.

That may not be as clean as a pure SQL solution, but it will work. You may also want to add a timestamp row to allow for a timeout on the lock.



PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to