On Fri, May 8, 2009 at 6:23 PM, Bogdan Stancescu <gutza@xxxxxxxxxxx> wrote: > 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 > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > What about creating a global variable or singleton class to hold the start of the transaction? This is something worth reading, as it indicates that the application should manage it ( http://stackoverflow.com/questions/319788/how-do-detect-that-transaction-has-already-been-started) and that transaction fall outside of OO scope. -- Bastien Cat, the other other white meat