Conversation
|
+1 |
|
This is a very useful feature and can help speed up integration tests which use the DB/fixtures by using savepoints rather than Thanks a lot for adding a test, @gluk-w. Would you mind fixing your formatting to match the style of this codebase? |
| public function commit() | ||
| { | ||
| // Nested transaction simply decrease number | ||
| if (--static::$transaction_counter) { |
There was a problem hiding this comment.
We should release the savepoint, and I think that should be done here.
http://dev.mysql.com/doc/refman/5.7/en/savepoint.html
http://www.postgresql.org/docs/9.1/static/sql-release-savepoint.html
|
Thanks @gluk-w! Apart from my notes and @jpfuentes2 note about the formatting I'm ok with this. |
| throw new DatabaseException($this); | ||
| // Transaction started already | ||
| if (static::$transaction_counter++) { | ||
| $this->connection->exec('SAVEPOINT trans'.static::$transaction_counter); |
There was a problem hiding this comment.
There will never be a trans0 like this, which I think is kinda odd.
|
And how does this work with the |
|
Also, do all PDO adapters support savepoints? I believe only postgres and mysql do, so we might take that into account in the implementation. |
I added support for nested transactions. So it is safe to start transaction and call methods that also use transactions. Implementation idea is taken from http://php.net/manual/en/pdo.begintransaction.php#116669