MySQL: did anyone start a transaction?

[email protected] (Bogdan Stancescu)
Newsgroups php.db
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.