transaction doesn't work properly - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17) +--- Thread: transaction doesn't work properly (/showthread.php?tid=68982) |
transaction doesn't work properly - vahid.vdn - 09-24-2017 I'm looking for a case how `transaction` do it's job. In first case I write a `sleep(10000)` between two queries, then turn of the wamp server: PHP Code: $this->db->trans_begin(); But first record is saved without second one. Then I tried with another case, that first query fails because of duplicated value: PHP Code: $this->db->trans_begin(); But again the new one exist in the database. Any idea? Is there anything I'm missing? Also `trans_rollback` doesn't work. PHP Code: if ($this->db->trans_status() === FALSE) RE: transaction doesn't work properly - vahid.vdn - 09-24-2017 I must use InnoDB in order to work with transactions! RE: transaction doesn't work properly - skunkbad - 09-24-2017 The problem is that since you are using trans_begin instead of trans_start, you are running the transaction manually. When running transactions manually, you don't want to use trans_complete, but you are. Remove trans_complete, and then you should be able to rollback or commit. RE: transaction doesn't work properly - vahid.vdn - 09-25-2017 (09-24-2017, 08:24 AM)skunkbad Wrote: The problem is that since you are using trans_begin instead of trans_start, you are running the transaction manually. When running transactions manually, you don't want to use trans_complete, but you are. Remove trans_complete, and then you should be able to rollback or commit. I don't want to use rollback or commit. In my case, the problem was with Storage Engine. It must be InnoDB. RE: transaction doesn't work properly - Narf - 09-25-2017 MyISAM strikes again. RE: transaction doesn't work properly - InsiteFX - 09-25-2017 LOL! @Narf RE: transaction doesn't work properly - skunkbad - 09-25-2017 (09-25-2017, 12:48 AM)vahid.vdn Wrote:(09-24-2017, 08:24 AM)skunkbad Wrote: The problem is that since you are using trans_begin instead of trans_start, you are running the transaction manually. When running transactions manually, you don't want to use trans_complete, but you are. Remove trans_complete, and then you should be able to rollback or commit. If you don't want to rollback or commit, then why are you using trans_begin instead of trans_start? You need to go back and read the docs related to transactions. |