0
我想要在codeigniter中捕獲數據庫錯誤(如重複值或錯誤號1062或1451),然後將其返回。請幫我解決這個問題。 *對不起,我英文不好*如何在codeignigter中捕獲數據庫錯誤
public function delete($id){
$this->db->where('pro_img_id', $id);
$this->db->delete('tb_image');
if($this->db->_error_number() == 1602){
return 'duplicate error';
}else if($this->db->affected_rows() > 0) {
return 'success';
} else {
return false;
}
}
傢伙謝謝:) – Vixar