[eluser]IanMcQ[/eluser]
Hi there,
I'm having some trouble figuring out the best way to handle database errors with CodeIgniter. Upon submission of one of my forms, I need to check for a database error, so I've gone like this:
Code:
$query = $this->db->query([...]);
// Form validation
if ($this->db->_error_number() == [...])
{
// display error
}
The problem is, the built-in CodeIgniter "Database Error" page takes over, which doesn't really allow me to handle the error on the form. I've considered turning db_debug off, but that would create another problem for me. I really like having db_debug on, because I've created a nice page where my users can physically submit in a bug report with the respective error. It's been very helpful in solving database issues.
So, my question is: how do I effectively handle MySQL database errors on my form
when I want to, but leave the unhandled errors to the stock CI "Database Error" page?
Any thoughts? Thanks in advanced.