我在 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 - 在 PHP/CodeIgniter 中,不止一个事务在没有完成另一个事务的情况下开始;比如嵌套事务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52056508/