I have a mysql Stored procedure that is called when a user should be deleted. Procedure signals an SQL state and throws error when someone tries to delete the row of Administrator Account. My Code in procedure is -
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Adminstrator cannot be deleted';
I am using CodeIgniter 3.1. I want to catch this error message WITH its sql state in my code. I looked into following links but no help -
1) CodeIgniter - how to catch DB errors?
2) Database Error Handling problem in CodeIngniter
What I observed was that there was a method $this->db->_error_number();
that could be used to get error number/sql state, but this is deprecated in latest version.
I wanted to know is there any way in CodeIgniter to get the SQL State if the database error occurs?
Any help would be appreciated.