2

Is there any way to get if currently I'm inside of any transaction? For example: get if MySqli::autocommit is 'on' or 'off'?

Need this because my project is using memcache, which should only be updated once all transaction success. I wanna assert user is not invoking update cache method in the process of any transaction.

Thanks in advance!

Leo
  • 35
  • 1
  • 4
  • 1
    possible duplicate of [How do detect that transaction has already been started?](http://stackoverflow.com/questions/319788/how-do-detect-that-transaction-has-already-been-started) – Déjà vu Jul 16 '14 at 07:23
  • Even if you `select@@autocommit`, it would return `0` if you start a transaction using `begin` or `start transaction`. – Pacerier Apr 09 '15 at 09:06

1 Answers1

1

There isn't a foolproof way to find out if a transaction has been started because, even if you usually use MySqli::autocommit to start one, someone could always issue the SQL to start a transaction. See the answers here:

How do detect that transaction has already been started?

Community
  • 1
  • 1
Reid Johnson
  • 1,394
  • 14
  • 20