DB transaction on non default DB group is not working |
[eluser]smilie[/eluser]
Hi all, I have one 'challenge' with DB transactions. Oke, I am loading DB group 'ns1': Code: $this->ns1 = $this->load->database('ns1',TRUE); This one, when printed states that it is actually DB connection and: [trans_enabled] => 1 [trans_strict] => 1 is in it as well, so far so good. Then I have following in the model: Code: // Start transactions: Problem is: Query 1 (in the loop) is executed and committed (I see changes in DB); Query 2 (executed once) fails (returns bool FALSE). Model return FALSE, meaning: if($this->ns1->trans_status() === FALSE) is indeed FALSE. However, my query 1 is not rolled back - changes remain in DB. I would expect from DB transactions to roll changes of query 1 back in case query 2 fails. But this does not happen ![]() Any idea's where am I going south with this one? Thanks! Cheers, Smilie
[eluser]porquero[/eluser]
What is your database engine? If is mysql, is running in InnoDB? Check this: http://ellislab.com/codeigniter/user-gui...tions.html Quote:CodeIgniter's database abstraction allows you to use transactions with databases that support transaction-safe table types. In MySQL, you'll need to be running InnoDB or BDB table types rather than the more common MyISAM. Most other database platforms support transactions natively.
[eluser]smilie[/eluser]
[quote author="porquero" date="1330092899"] What is your database engine? [/quote] MySQL [quote author="porquero" date="1330092899"] If is mysql, is running in InnoDB? [/quote] Yes, all tables are InnoDB; [quote author="porquero" date="1330092899"] Check this: http://ellislab.com/codeigniter/user-gui...tions.html [/quote] I read manual multiple times - but could not find any reference to why it should fail, nor about using different DB group ![]() Thanks for reply tho' Cheers, Aleks
[eluser]Mauricio de Abreu Antunes[/eluser]
Where is your rollback? :-) Is your strict mode enable?
[eluser]Mauricio de Abreu Antunes[/eluser]
In this case, you don't need to use transactions. Check your return update and just run next update if the first update is ok. Bye! |
Welcome Guest, Not a member yet? Register Sign In |