I have analyzed the code of the following Phalcon 2.0 classes:
Phalcon\Db\Adapter\Pdo
Phalcon\Db\Adapter\Pdo\Mysql
Phalcon\Db\Adapter\Pdo\Oracle
Phalcon\Db\Adapter\Pdo\Postgresql
Phalcon\Db\Adapter\Pdo\Sqlite
Phalcon\Db\Dialect
Phalcon\Db\Dialect\Mysql
Phalcon\Db\Dialect\Oracle
Phalcon\Db\Dialect\Postgresql
Phalcon\Db\Dialect\Sqlite
I wanted to find out how transactions works.
My founds:
(1) Phalcon supports nested transactions via savepoints only. It does not matter which database (dialect) we are using.
(2) In order the nesting works properly without any errors we need to switch the nesting ON in the bootstrap file in the following way:
$di->set('db', function () {
$connection = new DbAdapter([
//array with params here
]);
//switch the nesting ON
$connection->setNestedTransactionsWithSavepoints(true);
return $connection;
});
If you don't do this, then nesting will not work. I think this is very important issue and it should be highlighted in the docs.