Ok, let me make it out first. My question is like this: Unable to roll back transaction in Zend Framework
My tables are always innoDB, always. I checked the table in question and it is really innoDB. To the question ..
I have a database instance, and model instances going through this transaction end up in the same database:
$db->beginTransaction(); try { // Run an insert $model_record->insert(array('single_item' => 'its value')); // More logic, and run an update. $model_record->this_value = 'that'; // Save it $model_record->save(); //Commit the transaction $db->commit(); } catch (Exception $e) { // It finds the rollback, yet does nothing. $db->rollBack(); }
Now, the reason I didnโt work is to exceed the limit of characters in the string during the test to make sure that all the logic in place is correct.
He is not a rollback. In addition, an entry in "single_item" was in the database. But the updated values โโwere not.
I completely lost something small, I never had problems with transactions with MySQL and innoDB. Could this be due to MySQL or ZF? Any insight is helpful, thanks.
Update:
I did some more tests, and here are some results that may help:
$this->_db->beginTransaction(); // This works $this->_db->insert('table_a', array( 'a_field' => 'transaction test', ) ); // This does not work, at all. It inserts and does not rollback. There is no commit. $_table_a_model->insert( array( 'a_field' => 'transaction test', ) ); $this->_db->rollback();
Additional update You need to get an instance of the model and invoke the transaction.
$the_model = $this->_model->getAdapter(); $the_model->beginTransaction();
This leaves no room for transactions for multiple tables, without making multiple transactions for each instance of the model. Any ideas out there without returning to the underlying database instance?