Guest User

Untitled

a guest
Jul 17th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. try
  2. {
  3. $this->db->trans_begin();
  4.  
  5. if ( ! @copy('/source_dir/filename.jpg', '/destination_dir/filename.jpg'))
  6. {
  7. throw new Exception('failed copying file.');
  8. }
  9.  
  10. if ( ! $this->db->insert('table1', $mydata))
  11. {
  12. throw new Exception('failed inserting data.');
  13. }
  14.  
  15. $this->db->trans_commit();
  16.  
  17. $this->session->set_flashdata('message', 'all process succeeded!');
  18. }
  19. catch (Exception $e)
  20. {
  21. $this->db->trans_rollback();
  22.  
  23. @unlink('/destination_dir/filename.jpg');
  24.  
  25. $this->session->set_flashdata('message', $e->getMessage());
  26. }
Add Comment
Please, Sign In to add comment