在CodeIgniter中,如果抛出异常,事务期间会发生什么?
$this->db->trans_start();
$this->db->query('some query');
throw new Exception('error');
$this->db->query('some query');
$this->db->trans_complete();
我假设在trans_complete()
之前没有任何提交,但我在文档中找不到任何具体的证据。
为了将来参考,在调用trans_complete()
之前在查询之间抛出异常将导致没有按预期提交查询。
通过测试确认。