Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14115

How to gracefully degrade SQL errors

$
0
0
Hi all,

If I get an SQL error I'd like to log it and redirect the user to an error page which just informs them there has been an error.

The code I have tried below doesn't work (log_message doesn't work, the page isn't redirected and I just get the "Database Error Occurred" page.  The error (not the log_message part) is written to my log.

Where am I going wrong please?

Code:
// UPDATE
$this->db->where('fr_mach_date', $_POST['hdnMatchDate']);
$this->db->where('fr_team_code', $side);
$this->db->where('fr_double_banker', $double_banker_from);
if (!$this->db->update('fixtures_results', $arr_match_info))
//error updating the row.
{
log_message('error', 'Error updating fixture '.$_POST['hdnFixture_'.$side]);
#$error = $this->db->error();
redirect('week_fixtures/error');
}

Viewing all articles
Browse latest Browse all 14115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>