Created
August 31, 2012 02:08
-
-
Save jonathaningram/3547880 to your computer and use it in GitHub Desktop.
Doctrine MasterSlaveConnection beginTransaction connects to master but does NOT call parent method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
<?php | |
class NewMasterSlaveConnection | |
{ | |
public function beginTransaction() | |
{ | |
$this->connect('master'); | |
// *** Copied from the parent method except don't connect again *** | |
++$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