所以我有我的数据库事务的代码:
$to_return = true;
$this->db->trans_begin();
$this->insert_arrest_details($data);
$this->update_barangay($data['barangay_id']);
$this->insert_arresting_officers($data);
$folders = $this->insert_violators($data);
$this->insert_arrest_booking_form($data);
$this->insert_case_report($data);
$this->insert_seizing_officers($data['case_id'],json_decode($data['seizing_officers']));
$this->insert_items(json_decode($data['items']));
$this->insert_nitems(json_decode($data['nitems']));
$this->insert_violator_items(json_decode($data['items']));
$this->insert_violator_nitems(json_decode($data['nitems']));
if($this->db->trans_status() === FALSE){
$array['error_message'] = $this->db->_error_message();
$array['error_number'] = $this->db->_error_number();
$this->db->trans_rollback();
$to_return = $array;
}else{
$img_success = $this->move_violators_images($folders);
$img_success = $this->move_items_images($data['case_id']);
$img_success = 1;
if($img_success == 1){
$this->db->trans_commit();
}else{
$this->db->trans_rollback();
$to_return = false;
}
}
return $to_return;
我的问题是,如果错误(例如)发生在$ this-> insert_arrest_details();我的代码没有收到错误。它返回如下内容:
" ERROR_MESSAGE":""" ERROR_NUMBER":0
但是当我尝试仅运行1个方法并且该方法失败时,我的代码就能够得到错误。为什么会这样?
非常感谢您的回复。