2012-10-30 11 views
1

笨不返回錯誤號

$this->db->trans_start(); 
$deal_enquiry = $this->db->insert('deal_enquiry', $data); 
$enquiry_id = $this->db->insert_id(); 
$this->db->trans_complete(); 

if ($this->db->trans_status() === FALSE) { 
    echo $this->db->_error_number(); 
    if ($this->db->_error_number() == 0){ 
     $errormsg="Duplicate entry"; 
     return $errormsg;  
    } else{ 
     $errormsg="Enquiry failed"; 
     return $errormsg;  
    } 
    // return false; 
} else { 
    return true; 
} 

錯誤號總是返回0,即使有錯誤。當我將db_debug設置爲true時,錯誤號是不同的。爲什麼我沒有得到正確的錯誤號碼。有人可以指出這個問題。 謝謝,

+0

按照慣例,enything前綴_是一個私有成員。所以,你調用可能不會有一個默認的實現或超越私人/保護方法。總之,找到另一種方法,並嘗試只使用公共成員。 – MikeSW

回答

0

我通過回聲$這個 - >數據庫得到了錯誤號碼 - > _ ERROR_NUMBER();在trans_complete()之前; 感謝所有

0

對於其他人遇到類似的問題。確保你的database.php配置文件中啓用了數據庫調試。

相關問題