Commit 372e56d3 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge pull request #121 from frosas/master

Log transaction statements
parents d9c3509e 7c15f14e
......@@ -899,10 +899,24 @@ class Connection implements DriverConnection
++$this->_transactionNestingLevel;
$logger = $this->_config->getSQLLogger();
if ($this->_transactionNestingLevel == 1) {
if ($logger) {
$logger->startQuery('"START TRANSACTION"');
}
$this->_conn->beginTransaction();
if ($logger) {
$logger->stopQuery();
}
} else if ($this->_nestTransactionsWithSavepoints) {
if ($logger) {
$logger->startQuery('"SAVEPOINT"');
}
$this->createSavepoint($this->_getNestedTransactionSavePointName());
if ($logger) {
$logger->stopQuery();
}
}
}
......@@ -924,10 +938,24 @@ class Connection implements DriverConnection
$this->connect();
$logger = $this->_config->getSQLLogger();
if ($this->_transactionNestingLevel == 1) {
if ($logger) {
$logger->startQuery('"COMMIT"');
}
$this->_conn->commit();
if ($logger) {
$logger->stopQuery();
}
} else if ($this->_nestTransactionsWithSavepoints) {
if ($logger) {
$logger->startQuery('"RELEASE SAVEPOINT"');
}
$this->releaseSavepoint($this->_getNestedTransactionSavePointName());
if ($logger) {
$logger->stopQuery();
}
}
--$this->_transactionNestingLevel;
......@@ -949,13 +977,27 @@ class Connection implements DriverConnection
$this->connect();
$logger = $this->_config->getSQLLogger();
if ($this->_transactionNestingLevel == 1) {
if ($logger) {
$logger->startQuery('"ROLLBACK"');
}
$this->_transactionNestingLevel = 0;
$this->_conn->rollback();
$this->_isRollbackOnly = false;
if ($logger) {
$logger->stopQuery();
}
} else if ($this->_nestTransactionsWithSavepoints) {
if ($logger) {
$logger->startQuery('"ROLLBACK TO SAVEPOINT"');
}
$this->rollbackSavepoint($this->_getNestedTransactionSavePointName());
--$this->_transactionNestingLevel;
if ($logger) {
$logger->stopQuery();
}
} else {
$this->_isRollbackOnly = true;
--$this->_transactionNestingLevel;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment