I can normally check if a record is inserted using affected_rows()
but this record I am trying to insert causes an duplicate entry error and it makes the program execution stop.
Example: Using CodeIgniter
//Insert description
$this->db->query("
INSERT INTO comments_descriptions
(comment_id, description)
VALUES
(?, ?)
", array($commentID, $description));
This part is never reached:
if ($this->db->affected_rows() !== 1){
// Do stuff...
}
My AJAX call for this inserts only returns the number 500 and Firebug shows an internal server error every time I try to insert a duplicate statement. I have tried surrounding the insert in a try/catch
block and still the error is not caught. Please help.