【问题标题】:In PHP / CodeIgniter more than one transaction started without completing the other; Such as nested transaction在 PHP / CodeIgniter 中,不止一个事务开始了,而另一个事务没有完成;比如嵌套事务
【发布时间】:2019-02-03 00:09:59
【问题描述】:

我在 Codeigniter 中使用 HMVC
其中有inv_module的模型,一个是普通模型

首先$this->inv_module->model在数据库中存储一些数据,与mysql事务;
那么$this->inv_module->model的事务完成前$this->common->modal的模态调用,还有一个mysql事务。

谁能告诉我,当我的第一个事务没有完成并且通用模型的事务开始时会发生什么?

我的情况是这样的-

$this->db->trans_start();
$this->db->insert('tbl_categories', $category_array);

    $this->db->trans_start();
        $this->CI->db->insert('tbl_macro',$macro_array);
    $this->db->trans_complete();

$this->db->trans_complete();

此代码从另一个模型调用 -

$this->db->trans_start();
    $this->CI->db->insert('tbl_macro',$macro_array);
$this->db->trans_complete();

请任何人帮助我

【问题讨论】:

  • 有两个不同的事务。如果第二个失败,除非您这样做,否则它将对第一个没有影响。

标签: php mysql codeigniter phpmyadmin hmvc


【解决方案1】:

嵌套事务只会在其自身上提交或失败。

“外部”交易仍然有效。

【讨论】:

  • 但是如果嵌套事务放置在加载的库函数中,则外部事务不会回滚。你对这个案子有什么想法吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-11
  • 2016-06-30
  • 1970-01-01
  • 1970-01-01
  • 2015-03-27
  • 2021-08-28
相关资源
最近更新 更多