CodeIgniter中的手动事务

I'm trying to use Codeigniter transactions and as I am new to it, I really don't know to use $this->db->trans_begin() or $this->db->trans_start().

What are manual transactions and when should we consider it to be used.

And once the transaction is committed, should $this->db->trans_off() be used every time to continue auto-commit?

  1. $this->db->trans_start() and $this->db->trans_complete(); used together.

If Any query between those two statement fail it will do rollback them automatically.If success it will commit them automatically.

  1. But if you use $this->db->trans_begin(); any query after this line nothing will happen until you commit them or rollback them.

See Examples(from CI docs)

  1. http://www.codeigniter.com/user_guide/database/transactions.html#running-transactions
  2. http://www.codeigniter.com/user_guide/database/transactions.html#running-transactions-manually

$this->db->trans_off(); means you can disable transaction.Its up-to you whether you off it or not. I never use it, that means I always turn on transaction.see details