Revision #4 has been created by samdark on Aug 6, 2011, 1:03:08 PM with the memo:
Updated configuration for 1.1.8
« previous (#3) next (#5) »
How to use nested DB transactions (MyS
ql 5+, P gSql)
db, mysql, postgresql, transaction, nested
ource code taken from: [PHP, PDO & Nested Transactions](http://www.kennynet.co.uk/2008/12/02/php-pdo-nested-transactions/)
ested with: MyS
[...]With default Yii implementation, PDO will throw exception saying there already is active transaction.
But there's a solution:)
First, you'll need to extend PDO class and save it in your the protected/components directory:
Then, you'll need to alter the behaviour of [CDbConnection::createPdoInstance()]. You can do this by making a subclass of it in protected/components/NestedDbConnection.php
There, change $pdoClass to
lass name (NestedPDO in this example):
class NestedDbConnection extends CDbConnection
protected function createPdoInstance()
if($driver==='mssql' || $driver==='dblib')
return new $pdoClass($this->connectionString,$this->username,
Note that $this->_attributes was also changed to $this->attributes so the subclassing will work.
Now you can add the class name to the
db configuration array in
'connectionString' => ...
That's it, there you go