MySQL: did anyone start a transaction?
| From: | Bogdan Stancescu | Date: | Fri, 08 May 2009 22:23:10 +0000 |
| Subject: | MySQL: did anyone start a transaction? | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-46178@lists.php.net to get a copy of this message | ||
Hello all,
I asked this question on php-general last month
(http://marc.info/?t=124049230300004&r=1&w=2), and received some answers
-- but I was directed to this list, so here.
My question is: can I tell programatically whether the next query I'm
going to execute is already part of a transaction, using MySQL?
The context is thus: I'm writing a PHP library which attempts to
seamlessly merge database objects and PHP objects. Architecture
discussion aside (which I'm more than open to, if anyone cares enough to
talk), I need to know whether the code outside the library has already
started a transaction or not. I need to know that because I need to
execute both PHP and SQL from a single external call -- if either one of
my internal PHP or SQL calls fail, I need to revert to the original
state before the external call. And since transactions can't be nested,
I can't unconditionally start a new transaction when the external call
is being initiated -- therefore I need to know whether the programmer
has already started a transaction or not.
Thank you,
Bogdan