Skip to content

Instantly share code, notes, and snippets.

@jonathaningram
Created August 31, 2012 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathaningram/3547808 to your computer and use it in GitHub Desktop.
Save jonathaningram/3547808 to your computer and use it in GitHub Desktop.
Doctrine Connection beginTransaction method also calls connect, but implicitly on the slave connection which overwrites master
<?php
class Connection
{
public function beginTransaction()
{
$this->connect();
// **** Note: transaction nesting level is NOW incremented, so connect method does not consider it ***
++$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();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment