dpik71879 2015-06-30 06:01
浏览 15

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条回答 默认 最新

  • duanaozhong0696 2015-06-30 06:41
    关注
    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

    评论

报告相同问题?

悬赏问题

  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)