Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. $db->beginTransaction();
  2.  
  3. try {
  4. // Run an insert
  5. $model_record->insert(array('single_item' => 'its value'));
  6.  
  7. // More logic, and run an update.
  8. $model_record->this_value = 'that';
  9.  
  10. // Save it
  11. $model_record->save();
  12.  
  13. //Commit the transaction
  14. $db->commit();
  15. } catch (Exception $e) {
  16.  
  17. // It finds the rollback, yet does nothing.
  18. $db->rollBack();
  19. }
  20.  
  21. $this->_db->beginTransaction();
  22.  
  23. // This works
  24. $this->_db->insert('table_a',
  25. array(
  26. 'a_field' => 'transaction test',
  27. )
  28. );
  29.  
  30. // This does not work, at all. It inserts and does not rollback. There is no commit.
  31. $_table_a_model->insert(
  32. array(
  33. 'a_field' => 'transaction test',
  34. )
  35. );
  36.  
  37. $this->_db->rollback();
  38.  
  39. $the_model = $this->_model->getAdapter();
  40. $the_model->beginTransaction();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement