note 79157 added to ref.pdo
| From: | nospam dot list at unclassified dot de | Date: | Wed, 14 Nov 2007 00:24:31 +0000 |
| Subject: | note 79157 added to ref.pdo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132242@lists.php.net to get a copy of this message | ||
When using persistent connections, pay attention not to leave the database connection in some kind
of locked state. This can happen when you start a transaction by hand (i.e. not through the
PDO->beginTransaction() method), possibly even acquire some locks (e.g. with "SELECT ... FOR
UPDATE", "LOCK TABLES ..." or in SQLite with "BEGIN EXCLUSIVE TRANSACTION")
and then your PHP script ends with a fatal error, unhandled exception or under other circumstances
that lead to an unclean exit.
To use that database again, it may then be necessary to disable the persistence attribute to get a
new database connection or restart the web server. (Persistent connections should not work with a
PHP-CGI anyway.) It does not work (tested with PHP 5.2.3/WinXP and SQLite) to close a persistent
database connection - it will not actually be closed but instead returned to PDO's connection
pool.
The only thing you can do to resolve the lock as a regular user (I imagine) is to try and get all of
your persistent connections in a single script and unlock the tables resp. end the transactions with
the appropriate SQL statements ("UNLOCK TABLES" in MySQL, "ROLLBACK" for
transactions). Should they fail, there is no problem, but one or some of them might succeed and
thereby resolve your locking problem.
----
Server IP: 217.13.201.10
Probable Submitter: 88.217.116.155
----
Manual Page -- http://www.php.net/manual/en/ref.pdo.php
Edit -- https://master.php.net/note/edit/79157
Del: integrated -- https://master.php.net/note/delete/79157/integrated
Del: useless -- https://master.php.net/note/delete/79157/useless
Del: bad code -- https://master.php.net/note/delete/79157/bad+code
Del: spam -- https://master.php.net/note/delete/79157/spam
Del: non-english -- https://master.php.net/note/delete/79157/non-english
Del: in docs -- https://master.php.net/note/delete/79157/in+docs
Del: other reasons-- https://master.php.net/note/delete/79157
Reject -- https://master.php.net/note/reject/79157
Search -- https://master.php.net/manage/user-notes.php