Database Abstraction Layer for PHP

User Tools

Site Tools



int ADOconnection::transCnt


The value of $db→transCnt returns the current transaction nesting level. If no transaction has been started, the value is zero.

For granular transaction handling:

  • The value is always 1 when a transaction has been started, as nested transactions are not permitted.

For smart transaction handling:

  • The value indicates the nesting level of smart transactions. You should not modify the value of this variable manually, as this will likely cause a transaction scope failure.

You can check the value of transCnt to see if a transaction has been started. This is useful in, for example, loadable classes where the start point of a transaction might be in a different procedure.


if ($db->transCnt == 0)
* transCnt is now 1 Do some work
* transCnt is now 2
$db->execute('some insert statement...');
* Because the transCnt > 1, the completeTrans is ignored 
* transCnt is now 0, complete the transaction
v5/reference/connection/transcnt.txt · Last modified: 2016/04/14 15:56 by mnewnham