Finding out if a Doctrine or Propel transaction was started

If you have a Doctrine connection and you want to find out if a transaction was started on that connection, you can use the connection's getTransactionLevel() method.

function isTransactionStarted(Doctrine_Connection $connection) {
    return $connection->getTransactionLevel() > 0;

For Propel, the connection has an isTransactionStarted() method that you can use.

function isTransactionStarted(PropelPDO $connection) {
    return $connection->isTransactionStarted();