multiple transactions in one request. behaviour discussion

#1
[eluser]gtech[/eluser]
I have tested this with 1.6.x and the same problem occurs.

Here is an example of the problem.

Say a method within a controller invokes a model method with a database transaction, and then the controller method calls another model method that also has a transaction, the code works fine but if the first transaction causes a rollback the second transaction also fails and this is not my desired behavior.

I would like the second transaction to be successful even if the first one fails.

So why does the second transaction fail?

The DB_driver file sets _trans_status to TRUE once loaded in the request, however when a query fails _trans_status is set to FALSE. Thats fine but when trans_start is called the _trans_status flag is not reset.

In the DB_driver file I added a line in the trans_start function:
Code:
$this->_trans_status = TRUE;

and this fixes my problem Smile. Note you can use trans_start for manual rollbacks (you can still check trans_status === FALSE)

my questions are

what is the intended behavior?
Is resetting the flag in trans_start a good idea?
would it be good to add an optional parameter in trans_start that will be used to enable the calling function to reset the _trans_status flag?

[EDIT]
[url="http://ellislab.com/forums/viewthread/74497/"]someone else has had the same problem I should of searched the forums[/url]
[url="http://codeigniter.com/bug_tracker/bug/4299/"]and someone also has previously logged a bug[/url]


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.