2016-10-04 81 views
0

我有一個mysql應用程序刪除時調用的存儲過程。過程發出SQL狀態信號,並在有人試圖刪除管理員帳戶行時拋出錯誤。我的程序代碼是 -Codeigniter 3.1 - 獲取數據庫錯誤號

SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Adminstrator cannot be deleted'; 

我使用的是CodeIgniter 3.1。我想用我的代碼中的sql狀態來捕獲這個錯誤消息。 我看着下面的鏈接,但沒有任何幫助 -

1)CodeIgniter - how to catch DB errors?

2)Database Error Handling problem in CodeIngniter

我觀察到的是,有一種方法$this->db->_error_number();可能被用於獲取錯誤號/ SQL狀態,但是這在最新版本中已被棄用。

我想知道CodeIgniter有沒有辦法在發生數據庫錯誤時獲取SQL狀態?

任何幫助,將不勝感激。

+0

是這樣的: – TheRealVira

+0

http://stackoverflow.com/questions/5209332/codeigniter-how-to-check-if-there-is-anything-in-the-validation-error-array | http://stackoverflow.com/questions/7843406/codeigniter-how-to-catch-db-errors – TheRealVira

+0

我已經訪問過這些,沒有在最新版本中工作 –

回答